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.

2
votes
0answers
26 views

Custom indentation for macros in C mode

I'm working in a codebase with an extensive use of function macros and I'm having some difficulty finding the correct way to set indentations with them. Specifically, we pass a lot of statement lists {...
1
vote
1answer
23 views

How can I get flush left text in org-indent-mode?

I open an org file in emacs and it displays thus: I enable word wrap with M-x visual-line-mode and get: But I prefer the extra indenting of headlines provided by org indent mode, so then do M-x org-...
1
vote
1answer
31 views

Adding rule to indentation

A code base I work on has the macro #define when break; case to make switch statements 'cleaner' However this causes problems with indentation, Is it possible to set the behavior of 'when' to be ...
0
votes
1answer
1k views

How to assign TAB to indentation and to yasnippet expand key

i'm trying to have the key TAB to: Indent my code (like in any other text editor) Trigger Yasnippet I have theses lines in my config: (global-set-key (kbd "TAB") 'yas-expand) (global-set-key (kbd "...
1
vote
0answers
21 views

Align statement breaks on rhs with equal sign

Is there a way to have rhs statement breaks align with the equal sign on the lhs line? e.g. some_value = a * b + c / some_other_value * x; becoming some_value = a * b + c / ...
0
votes
1answer
58 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, ...
0
votes
1answer
18 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 ...
0
votes
1answer
41 views

Python Documentation String Indent In Auto-Fill Mode (Emacs 26.2)

I've noticed a peculiar behavior when using auto-fill-mode editing Python code. For example if I start typing the following (fill-column is set to 79): def some_function(keyword_argument0, ...
0
votes
1answer
22 views

Breaking up minified html

Is it possible to do this with vanilla emacs? If not what changes do I need to make. Original test.html <a id="try_redacted" target="_blank" href="http://redacted.com/game/2d/?try=1" style="right:...
11
votes
3answers
1k views

Customizing indentation in makefile mode?

In my makefiles, I prefer the following indentation for continuation lines: FILES:= \ file1.cpp \ file2.cpp \ fileYetAnother.cpp LIBS:= \ ...
0
votes
0answers
18 views

Convert gnu indent options to emacs indentation settings

I've worked at two places where code is supposed to be indented/formatted according to gnu indent (ie there's a prescribed set of options to gnu indent that's to be used). Is there an easy way to set ...
21
votes
5answers
15k views

How to pretty-format code (auto-insert newlines, indent, etc)?

I'm using spacemacs but presumably it's emacs knowledge that's required here. I have a JSON file with a single long line, let's say this JSON from json.org/example: {"menu": {"id": "file", "value": "...
0
votes
1answer
31 views

How to indent truncated lines?

For me it seems like a really ruff edge that default spacemacs comes without an option to give my lines a correct indentation, when they are wrapped. (Click the first link if you want to see the issue ...
1
vote
1answer
17 views

How to stop web-mode from reindenting after yank?

I'm editing this code: callFunction({ x: somearray, }); Then I want to extract somearray to be a variable with a copy. I cut somearray and delete the colon, then enter (_ is the cursor): const ...
1
vote
1answer
65 views

How to indent c++ “special” source lines that don't end with semicolons

I'm working with a system that uses special macros a lot. For instance: class UDSSLib : public UFunctionLibrary { GENERATED_BODY() void foo(); int i; } The problem is the GENERATED_BODY() line....
3
votes
1answer
32 views

SML Mode weird indentation

Whenever I hit enter to get to the next line when writing a function for example emacs indents an addition tabs worth of space. I'll try to sketch out the problem: fun pow(x : int, y : int) = ----...
0
votes
0answers
17 views

How do I disable full-buffer indentation after each yank in web-mode?

In editing html/php mix in web-mode, I inserted a single line by a yank 'C-y' and the full buffer (it says region) is re-indented. It takes a large amount of time. It even throws a warning: "Warning (...
0
votes
1answer
20 views

Keep text selection after indenting with evil

I'm using emacs with evil key-bindings and I like to know, after getting some text into visual mode, how do you make sure that after hitting >> for indenting the text, the selection is kept, ...
8
votes
1answer
156 views

Custom indentation for specific lines?

I currently try to figure out, how I can handle some lines specifically without messing up the indentation of the rest of the buffer. Consider the following function MyFunc as an example: void MyFunc(...
6
votes
2answers
600 views

Do not align nested calls when using ruby-smie

When using the newly added ruby formatting functionality I face the following problem: I would really like for my rspec code to be formatted like the following: it do is_expected.to match(/\[Error\...
0
votes
1answer
52 views

Indentation: 4 spaces everywhere

This morning, my Emacs changed its indentation rules, and now it indents by 2 spaces, specifically in JS and HTML. It even re-indents code on which I work to 2 spaces, which is unacceptable. Please ...
2
votes
0answers
22 views

Indentation with reader macros: common lisp in emacs

Okay, I'm not sure whether this question is more relevant to Common Lisp, or to Emacs. I have reader macros in Common Lisp (found them here), that allow the declaration of hash-tables by: #{'a 'b, '...
0
votes
2answers
332 views

prevent auto indent temporarily for multi line conditional, loops, etc

When I am writing in c-mode, I prefer to write multi-line control statements in the following way. if( cond1 && cond2 || cond3 ) { /* stuff */ } for( i = 0; i < N; ++i ) { ...
0
votes
1answer
323 views

How to fix incorrect emacs C#-mode indentation for method braces

My problem is that Emacs incorrectly indents the braces for C# methods, like this: static string LOL() { } then I have to manually correct it to static string LOL() { } I have read ...
2
votes
2answers
743 views

Python docstrings only allow two indent levels

I am trying to write a docstring that follows Google's style guide such that it looks something like: def testFunction(a, b): """ Args: a (str): b (str): Returns: ...
0
votes
0answers
45 views

Evil-mode mixed tabs & spaces indentation

I'm having extreme issues at the moment with evil mode where I am working on Jade/Pug and Stylus files for Node.JS where it is white space sensitive. I installed pug-mode but when you indent via >> ...
5
votes
1answer
31 views

Indentation of description lists

org-mode automatically indents description lists, but it uses two different schemes. For short labels, the second line of the description is aligned with the first character of the description. For ...
4
votes
1answer
653 views

How to turn off alignment-indent after line continuation in Shell-script mode?

In Shell-script[sh] mode, Emacs defaults to this style of indentation: /this/is/an/example/command/broken/over_multiple_lines which \ causes \ ...
2
votes
1answer
64 views

Manual indentation in LaTeX mode

I'm new to Emacs, and dislike the default indentation in LaTeX mode. I want the indentation to do the following: insert a \t character (not spaces) be completely manual (I want to have to press Tab ...
0
votes
1answer
43 views

Previous indentation is discarded on newline

Let's say I have the following code: void foo(){ ~ } I have marked point with ~. When I press enter the electric indentation works as normal but it doesn't keep the indentation for the previous ...
0
votes
1answer
78 views

opening brace alignment/indentation problem in LaTeX mode

I have an alignment/indentation problem in LaTeX mode. Every time I begin a line with an opening brace and I hit <TAB> or run an indentation command on the region, the brace becomes aligned with ...
1
vote
0answers
47 views

How to fix indentation of C++ methods with ref-qualifiers?

Emacs in its default configuration seems to have trouble indenting C++ methods with reference qualifiers (& and &&). For example: struct foo { void a_method() && { ...
2
votes
1answer
48 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
0answers
13 views

Can I force erlang-mode to use 4-spaces for indents?

I'm working within a small team writing Erlang. I'm the only developer using Emacs. The Erlang code the rest of the team outputs is indented using multiples of 4 spaces. For example: ...
0
votes
1answer
31 views

Indentation broken with all \input{files.tex}

Everything is in the title : a master.tex file contains several \input{subfileXX.tex} ; the indentation works in the master file but not in the subfiles. The TAB key acts like in LibreOffice.
1
vote
2answers
37 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 = "...
1
vote
2answers
98 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 ...
2
votes
0answers
26 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 ...
3
votes
2answers
197 views

White space being inserted before a semicolon in asm-mode

When I try to insert a semicolon in my code (in asm-mode) it seems to indent a certain number of tabs like this (usually 4 it seems): D ; And if I put another semicolon on the next ...
1
vote
2answers
146 views

Emacs bulk indent for Python while `cua-mode` is enabled

I'd like to know how to indent multiple lines while Python is my major mode. The link below answers my question for the most part: https://stackoverflow.com/questions/2585091/emacs-bulk-indent-for-...
1
vote
1answer
34 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 ...
2
votes
1answer
58 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
161 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
2answers
348 views

how to paste with indent

the code block I copy outside emacs, which is not auto-indent when yanking in org type org-return-indent -> yank code block -> indent manually: *** headline | v *** headline { code ...
1
vote
1answer
208 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, ...
1
vote
1answer
41 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
0answers
22 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 ...
4
votes
2answers
345 views

sh-script alignment issues

I'm sure emacs used to do it my way, but things appear to have changed (probably years ago, I've just been living with the pain). I want this (to conform to corp. standards): MULTIFORM=$( curl -...
0
votes
1answer
81 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? ...
2
votes
1answer
764 views

Minor mode for editing ansible playbooks

I have recently started using ansible, and yaml-mode seemed the logical choice for editing playbooks. However, the indentation does not quite work correctly. For example, I might start a task ...