Questions tagged [indentation]

Indenting is used to organize code by indicating blocks, closures, conditionals, and other constructs. It makes code easier to read, and in some languages is used to handle control flow.

Filter by
Sorted by
Tagged with
0
votes
0answers
16 views

Python indent region is wrong

Given the code: def main(args=None): if args is None: args = sys.argv[1:] load_data() Calling indent-region on the code (under python mode), the output would be: def main(args=None): ...
3
votes
1answer
55 views

Can we do `C-c >` and `>` and `>` to continue indentation

I am using following answer to handle indentations Emacs bulk indent for Python C-c > or C-c C-l shifts the region 4 spaces to the right C-c < or C-c C-r shifts the region 4 spaces to the left ...
0
votes
0answers
13 views

adaptive-wrap-prefix-mode behavior is different/inconsistent inside a buffer

in org-mode I have adaptive-wrap-prefix-mode on. The indentation though has a inconsistent behavior. I have already tried to toggle visual-line-mode and word wrap but the sometimes correct and ...
0
votes
1answer
35 views

Javascript mode mixes tabs and spaces for indent

My javascript mode indents with a mix of tabs and spaces. I'm ok with the mix if spaces are used for cosmetic alignment, but this is just wrong: First level of indentation is spaces, second is tab, ...
0
votes
0answers
20 views

Wrong indentation of block directives in rst-mode

I'm having issues with indentation of block directives in rst-mode. Colons in the directives are always indenting, and I always have to backspace to get it back on the right line. But even backspace ...
0
votes
0answers
12 views

How to set indentation in cperl mode

Here is the code: $app->helper('turizm_images__get_validation_params' => sub{ my $c = shift; my $config = $c->config('upload'); Is it possible to ...
0
votes
1answer
39 views

How to set js-mode indent in Emacs >= 27.1

I have my tab width set to two spaces and this has worked fine for many years. I have just upgraded to Emacs 27.1, and now js-mode is displaying tabs as three spaces wide, ignoring my preferred ...
1
vote
2answers
23 views

Indentation by using AST from external program

I'm pondering over doing indentation by using an AST created with an external (non-emacs) tool. But so far I do not really know where to start. Are there emacs packages which already did this? Any ...
0
votes
0answers
31 views

SMIE: if-elseif-else constructs

I'm struggling with teaching SMIE how to handle if-elseif-else constructs correctly. In the following test file the indentation of the last line, i.e. xoxox;, is wrong. I suppose something's wrong ...
1
vote
1answer
27 views

Maintaining consistent visual fill column under `org-indent-mode`

How can one enable org-indent-mode (or otherwise indent content to Org headings) while still maintaining a consistent visual fill column?
0
votes
0answers
2 views

Indentation for typeclass in coq mode

In coq-mode for typeclasses in shifts the braces: Class Group G : Type := { e : G; mult : G -> G -> G; inv : G -> G; }. Is it possible to disable the braces indentation and ...
0
votes
0answers
12 views

Indentation with uniform initialization spanning several lines

This is how the following line is currently indented for me: std::array<int, 4> arr { 54, 37, 54, 37 }; However, I would like it to be indented like this: std::array<int, 4> arr { 54, ...
0
votes
0answers
59 views

SMIE — Indentation After Comments

I've written a very simple mode using SMIE (see code below) that produces some weird indentation after comments that I do not understand. Here is an example: int a /**/ ; int b; int a /**/; int ...
0
votes
0answers
79 views

elisp mode set tab width to 2 spaces

My global tab-width is set to 4. But in elisp-mode I get 6 spaces per tab in indentation. So the code after auto indenting looks like this: (defun new-eshell () (interactive) (when (one-...
1
vote
0answers
7 views

yas-expand doesn't trigger reindent in aggressive-indent-mode

I'm trying to make a call to yas-expand doesn't trigger aggressive-indent. I'm guessing this is because yas-expand, for some reason, doesn't trigger a call to after-change-functions into which ...
1
vote
2answers
70 views

How to NOT Auto Indent when a specific Character is inputted?

So I recently encountered a problem programming in C that whenever I enter the left parenthesis character, (, Emacs auto-idents the code. [4 spaces here]DATA *SeqQueueOut( I know that there is this ...
0
votes
1answer
84 views

How to set python indent offset to 2 spaces in elpy emacs?

I use elpy package for Python 3 in Emacs. It uses yapf to format a Python buffer. I have tried about everything, setting tab-width to 2 and setting python-indent-offset to 2 but nothing makes it so ...
2
votes
0answers
43 views

Unexpected indentation in python chunks

Already one year ago, I described a problem on github with polymode and unexpected indents. Since there was no answer there so far and the problem is really annoying, I ask here for ideas for a ...
0
votes
1answer
34 views

Change `standard-indent` for 1 specific major mode

I author web apps with the web-mode in GNU Emacs, and I use 2 spaces for indentation. After I examined the web-mode source, I found out that the mode defaults to the standard-indent variable, which in ...
0
votes
0answers
9 views

Apropriately indent multi-line x=($()) in shell-script-mode?

Bash allows capturing output of a subshell as elements of an array line-by-line with the construct IFS=$'\n' myArray=($(someCommand)) However, auto-indentation fails to produce a useful result for ...
1
vote
1answer
18 views

How to append spaces to align by next word in the line above

I am looking for a function helping indenting imports. I noticed following pattern. Origin file: import A.B.C (x, y, z) Result file: import qualified A.B.C (x, y, z) import ...
1
vote
1answer
82 views

C++ mode, indendation confusion

Today I realized something odd that bothers me. Here is a little example of a function I wrote. I am using armadillo, but that is is unimportant. Here, the indentation looks just fine. float GetE0() { ...
0
votes
0answers
6 views

How to fix indent of multiline dotpaths in javascript

I would like my code to look like this: this.imgs.push( $('<img>').attr('src', data.src) .css('position', 'absolute') ); this.imgs[i].css('left', data.x) ....
0
votes
0answers
171 views

Make tabs behavior like in other IDEs

How can I force Emacs to use tab button and TAB character in "normal stupid way"[1], like in nano or VScode or JetBrain's IDEs. All I can find is smart-tabs package and indent-tabs-mode, but ...
0
votes
1answer
38 views

How can I insert some multiline text that respects the indentation at which it is inserted?

I have a function that reads a link from the clipboard and generates a metadata-ful markdown link from it, and inserts it: (defun night/unt () (interactive) (let* ((link (current-kill 0)) ...
2
votes
1answer
119 views

Emacs auto-indenting comments in an unhelpful manner

New Emacs user here. Hitting enter after a semicolon commented line in any file type (.el and .lisp at the very least) indents the comment in a very unhelpful way that I have to assume is not intended ...
1
vote
1answer
24 views

How to disable `clean-aindent-mode` in spacemacs configuration

I noticed that clean-aindent-mode is messing up the indentation as I am writing python files. Hence, I wanted to disable this mode, at least when using python mode. I can manually disable this mode, ...
1
vote
2answers
146 views

How to turn off automatic indenting for Org files in a specific folder?

I am using Doom Emacs. I like having indentation for most of my org files, but I have one folder where I want to have org files without indenting, to use for writing documents. I have already tested ...
1
vote
1answer
80 views

How do I make emacs indent relative to the beginning of the previous line?

Here's how emacs indents e.g. Python code: a = myfun(b, c) I'd like it to be this way: a = myfun(b, c) Reasoning? If I later replace myfun with myfunction, in the first case it becomes:...
0
votes
0answers
22 views

Aligning the colon in multi-line tertiary expressions in C and C++

Suppose I have the following line double dx = r1 < 1 ? sqrt(r1) - 1 : 1 - sqrt(2 - r1); I press enter and tab at the colon causing Emacs to align like this: double dx = r1 < 1 ? sqrt(r1) - 1 ...
0
votes
0answers
40 views

Unable to change emacs python indent

My Emacs's python-indent-offset is fixed at 2, even though I have the below code in my init.el to set it to 4. I used C-h v to describe the variable, it says its value is 2 and default is 4. I removed ...
1
vote
1answer
40 views

Spacemacs gg=G replacing tabs with spaces in org-babel makefile block

I'm using Spacemacs, and my org-mode file contains an org-babel block of Makefile code, which I want to "tangle" so it becomes part of the source code while remaining in sync with the ...
0
votes
1answer
21 views

Auto-indentation for Meteor/spacebars

How do I get Emacs to auto-indent Spacebars blocks when coding with Meteor? Right now, Emacs automatically does this: {{#each player}} {{name}} {{/each}} instead of this: {{#each player}} {{name}}...
0
votes
0answers
37 views

web-mode - PHP code indentation

I have been using Emacs for some time but I am quite new for PHP and Web development. I want to use Emacs as a PHP editor. I have searched a lot of pages and I have found that many people recommend ...
0
votes
0answers
15 views

Correctly indent whole buffer in auctex wihtout filling

When using AUCTeX to edit LaTeX files you can call LaTeX-fill-buffer to fill the whole buffer and additionally indent everything correctly. However if I am using visual-line-mode (together with ...
0
votes
0answers
8 views

nxml: Indent tag attributes on new lines 4 characters, not below attribute on parent line

I put attributes for XML tags onto a new line when the tag line gets too long: <flux:field.inline.fal name="settings.image" required="1" maxItems="1" minItems="0" collapseAll="1" ...
0
votes
0answers
12 views

Custom indentation blocks in c++-mode?

Is it possible/easy to add custom markers for the start/end of indentation blocks in c++-mode? I'd like the indentation of a block of code like BOOST_AUTO_TEST_SUITE(SuiteName) // <<TestCases&...
2
votes
1answer
43 views

Python over-indentation warning E127

elpy (or rather flake8 I suppose) complains about a line over-indented on the line 52 (see below image) I tried to change this line's begin but no change. I always use TAB to have the correct ...
0
votes
0answers
18 views

Making input easy to read (Macaulay2)

I am using Emacs to run Macaulay2 (I'm a newbie at both). I have a long input written in an m2 file, which I then press f11 to input to Macaulay2. I would like to make my input more aesthetically ...
0
votes
0answers
24 views

SMIE: bare opener forces “hanging” indent

If I use the default SML mode parser, or other SMIE parsers, and have a rule for if-then-else as an expression form, I get reasonable indentation of x + if p then q else ...
0
votes
1answer
26 views

SMIE precedence conflict

(defvar foo-smie-grammar (smie-prec2->grammar (smie-bnf->prec2 '((exp (exp "+" exp) (exp "*" exp) ("let" let-decls "in" exp)) (let-decls (let-decls ";" let-...
0
votes
0answers
28 views

How to fix indentation of anonymous structures in function argument position in C?

I've been stumbling upon this constantly. Suppose that I have a function that accepts a structure, or a pointer to a structure: struct s { int n; char c; }; void f(struct s *s); I'd like to ...
1
vote
0answers
13 views

auto intendation on newline doesn't stay at same indentation for python docstring

Ubuntu 19.10 emacs 26.3 from system repos I do use elpy and evil-mode In general when I am editing python code, indentation works just fine. However, when I am editing doc-strings, when I type enter ...
1
vote
1answer
32 views

setq in init file not overriding the default for indent-tabs-mode

It works when using setq-default in place of setq or when customizing through C-h v. C-h v reports that it is set in 'C source code'. I was thinking it might be affected by my c-default-style, but my ...
0
votes
0answers
27 views

Editing mode for OpenBSD .conf files

Can GNU Emacs edit OpenBSD configuration files (/etc/*.conf, curly-brace syntax) with auto-indentation and syntax highlighting? conf-mode does not seem to handle that syntax in Emacs 26. c-mode ...
1
vote
2answers
65 views

Always show the last lines with a lower indentation than the first line that's visible in a window

I often find myself scrolling up in a code file to see which context I am in (class/method definition, yaml-key, etc). It would be super handy if I could somehow "freeze" the last lines of each ...
0
votes
0answers
13 views

smie handling of expression prefixes inside its s-expressions

In the SMIE implementation of SML, ! is given the "expression prefix" syntax class. This seems to lead to a strange tokenization, such that its notion of s-expression (e.g.,if-then-else blocks) gets ...
0
votes
3answers
59 views

How to disable autoindent on new line?

I find a lot of questions similar to this, but not one with an answer that matches what I need. I'm using spacemacs in evil mode, and I want "new lines" (done with RET in insert mode, or o or O etc) ...
0
votes
1answer
23 views

Need help with JavaScript `{` indentation

I'd need some guidance with adjusting my indentation settings for js-mode (JavaScript). It should basically look like C/C++'s Stroustrup mode. Most of it works as expected, however there are some ...
0
votes
0answers
9 views

how to differently indent different regions in the same buffer?

I have some scraps of xml and some scraps of scheme in the same buffer I'd like to indent the xml with svg-mode and scheme with the scheme-mode I know that org mode can do that but that is ...

1
2 3 4 5
10