Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

1
vote
2answers
28 views

Getting electric indent behaviour for added chars to “electric-indent-chars”

I am trying to get electric indent behaviour in bazel BUILD files. These are essentially python files, although the structure is extremely simple. Let me give you an example: cc_binary( name = "...
2
votes
0answers
17 views

Letting evil >> increment org level

In evil mode, >> increments the indentation level of the current line. It does so at an org heading too, even though it would be more appropriate there if it would increase the org level (the ...
2
votes
0answers
39 views

How to control JavaScript indentation?

I am coding in Node.js, each time I want to write something that looks like this: const product = Factory .model('App/Models/Product') .create() I get this as an output: const product = Factory ...
0
votes
1answer
22 views

CC mode: make Tab just insert one tab or complete, no auto-indenting

I am dissatisfied with current behaviour of Emacs in CC Mode. I'm not sure if this applies to other major modes, but that's one I'm currently struggling with. Here are my problems: When I press tab, ...
1
vote
1answer
15 views

Which variable modifies the switch statement indentation on php-mode?

I am currently using php-mode with spacemacs to write in php and recently I noticed this auto-indent behavior, namely pressing TAB. switch ($cond) { case "something": break; } Auto indenting ...
1
vote
1answer
75 views

Can’t guess python-indent-offset - delete warning when local file variable

I have this comment that I write in my python file # -*- Mode: Python; tab-width: 8; indent-tabs-mode: nil; python-indent-offset: 2 -*- # vim:set et sts=4 ts=4 tw=80: But when I load a python file, ...
0
votes
0answers
20 views

unexpected long indent after colon in web-mode

I have some trouble locating the source of 8 tabs and 3 spaces more than the previous indentation when I'm inside js inside web-mode. These appear after a line that ends with a colon. Example (note ...
1
vote
1answer
31 views

Indent forwards a tree structure

I have such a structure in my org note **** pstree * ~ $ pstree -aps 26955 systemd,1 splash └─systemd,1947 --user └─gnome-terminal-,2710 └─bash,1775 └─emacs,25135 ...
0
votes
1answer
11 views

How do I suppress indentation after labels in Groovy?

I'm writing some Groovy code, and in my unit tests I have something like the following: def testFoo(){ given: //setup statement 1 //setup statement 2 //... when: //Execute ...
2
votes
1answer
51 views

Emacs indents C++ functions in structs in an unexpected way

Emacs indents functions in structs in the following way: struct A { int a() { return 1; } int b() { return 2; } } int c() { return ...
0
votes
1answer
73 views

highlight-indent-guides-mode

I'm trying to activate highlight-indent-guides-mode by default but it is not working. If i do M-x highlight-indent-guides-mode it works fine but adding (highlight-indent-guides-mode 1) to my .emacs ...
0
votes
1answer
57 views

How to set tabulator size in the awk mode?

After installing a new kubuntu (16.04) and emacs (25.2.2) I have had indentation problems. It seems like indentation default values have changed or maybe I am missing some configuration file? ...
1
vote
2answers
72 views

Babel + Python function definition with for loop causes IndentationError

I am using orgmode and Babel to run Python source code blocks. I noticed that if I define a function that returns a value, and if this function has a for loop inside it, then evaluating it with Babel ...
0
votes
2answers
24 views

Automatic re-indentation

I'm using Emacs to write ocaml programs, and the automatic indentation works fine : suppose I write if in the middle of a line, then skip a line and write then ; the keyword then is automatically ...
0
votes
1answer
39 views

Customizing indentation style for continuation lines?

I would like to customize the "k&r" indentation style, so that continuation lines are indented 8 spaces, like this: if (first && second) { // <- 8 spaces. third(); } -- ...
0
votes
2answers
109 views

Confusion about space and tab characters in Emacs

I am confused by space (SPC) and TAB characters in Emacs. I am often using the default fundamental mode. When I select a region and indent the lines in the region by C-u 9 C-x TAB, I intend to ...
0
votes
0answers
29 views

Prevent spacemacs from splitting lines of C++ code

I installed the c-c++ layers in Spacemacs. When I invoke indent-region, Spacemacs splits lines that are longer than 80 characters. How can I prevent this behavior? auto-fill-mode is not enabled and ...
2
votes
0answers
68 views

Strange comment indentation results

I am working with a simple major mode. The format has one single line comment delimiter, i.e., %. However, I get strange results when running fill-paragraph on a comment. Specifically, the result I ...
1
vote
1answer
32 views

Unexpected indentation in backquoted list starting with comma function call

When I write a backquotedlist that starts with ,( emacs aligns the remaining items to the parenthesis and not to the comma; e.g.: (defun kb-test1 () `(,(hello) fdefef ,(fefesd))) (...
0
votes
1answer
104 views

Automatically indent ONLY logical lines in Org-mode

I want this: ** This is a heading This is a logical line. But, because I have visual-line-mode on, lines will wrap at the edge, as is just and godly. But, such elegant formatting as you see here ...
1
vote
0answers
77 views

c++ mode indentation

If we have a class like the one below emacs is indenting the : (to the initialization list). To be able to match some other editor, is it possible in emacs to indent the : like below? class Test { ...
-1
votes
1answer
79 views

Why does emacs sh-mode ignore indent-tabs-mode?

sh-mode won't care if indent-tabs-mode is on, it will still insert spaces instead of tabs! Can this be fixed?
0
votes
1answer
86 views

Emacs: indentation takes 4 spaces instead of 2

When I write code in Emacs and press Return, the indentation is automatically set to 4 spaces even if I set it yo 2: (setq tab-width 2) ; or any other preferred value (defvaralias 'c-basic-offset ...
3
votes
1answer
39 views

formatting of elisp file is different in emacs and other text editor

I'm having an issue with formatting in that when I'm in emacs, the formatting looks fine: but when the file is viewed with a different text editor, the spaces are different. this only occurs in the ...
1
vote
1answer
95 views

#ifdef __cplusplus nuisance: How to prevent extra indenting?

If you ever wrote header files that have to be used by both C compiler and C++ compiler, you'd encounter this particular ifdef. This construct causes one to insert extra curly braces in the header ...
0
votes
2answers
45 views

How to configure C-M-q and TAB key to expand pre-existing TAB characters into spaces in C/C++ files

In C and C++ files, I want to configure the mode so that any time I request indentation, that it will always expand all of the embedded TAB characters in indentation (at the start of the line, and no ...
0
votes
1answer
54 views

Disable `indent-relative`

What's the right way to disable Emacs' default indent-relative behaviour and make sure that TAB always indents by a single level (be it a tab or whitespace character)? There doesn't seem to much ...
0
votes
2answers
66 views

How to prevent losing indentation when editing JavaScript code within HTML files in Emacs?

When I edit JavaScript code which exists in an HTML file, I lose code indentation whenever I press Enter. first line of code: second line of code # Press Enter here Result after pressing Enter: ...
0
votes
1answer
264 views

cuda .cu files indentation issue. How i can set indentation for cuda .cu files to 4 spaces?

In my .emacs i have put following for cuda highlighting: (setq c-default-style '(("c++" . "linux") (java-mode . "java") (awk-mode . "awk") ...
0
votes
1answer
49 views

How to reveal tabs in the indentation in a cpp file?

My friend and I collaborate on a C++ project and we agree to use 4 whiltespaces for indentation. I am using Emacs and this is my indentation setting (setq-default c-basic-offset 4) By doing this, I ...
1
vote
0answers
58 views

C++-mode indenting performance depends on length of previous function?

Using c++-mode in emacs23. UPDATE: In response to some early comments, I tested on emacs24 and emacs25, and see exactly the same behavior. I don't have convenient access to emacs26 or emacs27 (25 ...
2
votes
1answer
31 views

Electric indent: Inserting blank lines with no whitespace while keeping cursor indented?

I do a lot of python coding and am trying to determine if electric indent can be customized to help me with the following scenario: Let's say my cursor (point) is at the end of the following excerpt, ...
0
votes
1answer
171 views

Unwanted indentation in org + evil

From an org heading, pressing evil o will open a new line that's indented according to the heading (org level + 1 spaces). Can this behaviour be turned off?
2
votes
1answer
22 views

In M-x Info (C-h i), tables are not correctly aligned

Problem When trying to browse documentation in M-x info ≡ C-h i, the table of contents is not correctly aligned. One would expect * Introduction This is the etc etc etc etc etc . * Details ...
3
votes
1answer
128 views

Make emacs to use only tabs for JS indentation

I've set my tabs to 4 and haven't changed any JS indent settings. All the indents I found in the "JavaScript group" have values either 0 or 4, yet the following code describe('test Info', () => { ...
0
votes
0answers
27 views

JDEE following line indentation

Is there any way to indent the following lines in e.g. a function to less than the opening brace. Instead of public static void fun(String hello, String world) { ... it would ...
2
votes
1answer
84 views

Indentation of multi-line arrays within braces?

Currently in C mode, contents of a muli-line arrays are aligned with the brace. eg: const unsigned int array[4] = { A, B, ...
0
votes
1answer
462 views

How to indent with the tab character with a visual length of 4 spaces in spacemacs?

I have used Vim for years now, Emacs for a couple of weeks and recently switched to Spacemacs. How do I set indentation settings either globally or the C/C++ mode? (A solution for either one is fine.) ...
0
votes
0answers
33 views

How to enable SHIFT+TAB for multi line code region unindentation?

I have found this code which enables both TAB and SHIFT+TAB for code region indentation and unindentation. The problem is SHIFT+TAB doesn't work on multi line codes and also we have to place the ...
6
votes
2answers
162 views

Org-mode : disable indentation when promoting and demoting trees + subtrees

In org-mode, when you press M-S-right or M-S-left to demote or promote a tree with all it's subtrees, the content text is also indented. So suppose I want to deomote the following structure by two ...
0
votes
0answers
51 views

Spacemacs + Coffee-mode, indents keeps doubling

I'm relatively new to spacemacs. I am editing a coffee-script file, so am using coffee-mode The indents keeps doubling... so 4, 8, 16, 32 .... the further I nest... Example what's wrong: (When I ...
0
votes
0answers
56 views

web-mode indents unclosed tags

The following is valid HTML. <p><a href="page1.html">Page one</a> <p><a href="page2.html">Page two</a> <p><a href="page3.html">Page three</a> ...
1
vote
1answer
29 views

Indentation incorrect in line with `if:` or `unless:` as options, not directives

In some of my ruby files, mostly Rails Model files, I often encounter lines such as: validates :thing_id, presence: { message: '^Choose a Thing' }, on: :create, unless: Proc.new { |obj| ......
4
votes
0answers
66 views

indent cl-loop to respect `if else` statements

I have a hard time writing and reading cl-loops with they way they're indented by default as I can't easily tell what the control flow is: (cl-loop for x below 10 if (cl-oddp x) ...
0
votes
1answer
23 views

get “jump to column” behavior of fundamental mode in a major mode

I noticed that when in fundamental-mode or prog-mode (basically any mode without an indent-line-function) the TAB key will jump between columns. For example if I have foo bar baz fot bat| ...
1
vote
1answer
58 views

javscript “.” indent in web-mode

In web-mode, the indentation after "." var context = cubism.context() .step(1e4) .size(+d33.select("#using-cubism2") .style("...
0
votes
1answer
127 views

Single/simple way to set indentation to 2 for all modes

I'm a bit confused about setting indentation for different modes in Emacs. It seems you have to explicitly set indentation for each mode Some modes use setq-default, some use setq and some use add-...
4
votes
1answer
110 views

Bash script is indented inconsistently

Open the code below with emacs -q, do set-variable sh-basic-offset 2, then indent-region. All lines are indented with 2, while the echo line is indented with 4. Is this a bug in Emacs, or how do I ...
0
votes
1answer
60 views

pressing return in paragraph-indent-text-mode deletes whitespace indenting beginning of paragraph

I'm currently using emacs 25.3 on Mac OSX installed using Homebrew, and without any modifications in my .emacs file or anywhere else. I think I may be fundamentally misunderstanding what paragraph-...
1
vote
0answers
112 views

org-cycle behaves differently for src blocks when evil-mode is enabled

I'm trying to indent my code in org src blocks, but it only works when evil-mode is disabled. I have set this variables for org-mode: (setq org-src-preserve-indentation t org-src-tab-acts-...