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.

526 questions
48
votes
5 answers

How to disable auto-indentation of new lines?

I've recently upgraded emacs to version 24.4.1 and something has changed in the indentation of new lines. When I hit enter I expect just "bare" new line character at point where cursor was present, in particular if I'm in the middle of the line,…
38
votes
7 answers

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": "File", "popup": {"menuitem": [{"value": "New",…
Emmanuel Touzery
  • 961
  • 1
  • 8
  • 17
28
votes
5 answers

Different indentation styles for different projects

I work on many different C projects with unique indentation styles. How do I get Emacs to do per-project indentation settings without polluting the upstream project trees with .dir-locals.el files? I want to match the projects using their paths on…
artagnon
  • 2,237
  • 1
  • 15
  • 17
23
votes
3 answers

Is there any SMIE documentation that is clear?

I've spent many, many hours now trying to get any sort of SMIE indentation rule/grammar/thing working. Are there any examples of a small, toy or skeleton SMIE-based mode with documentation on how it actually works, or any discussion anywhere about…
Nagora
  • 373
  • 1
  • 9
23
votes
4 answers

How to indent keywords aligned?

Probably influenced by Clojure, I more often use property lists as data-structures. Emacs most of the time indents them like this, `(:token ,token :token-quality ,quality) , while this is what I would prefer `(:token ,token …
politza
  • 3,316
  • 14
  • 16
20
votes
2 answers

Completely disable all auto-indentation

How do I completely disable all auto-indentation in Emacs? I need to disable it at least for Fundamental mode, but I'm fine with it being disabled globally for the current session. Please read the rest of this question before declaring it a…
Mr Fooz
  • 303
  • 1
  • 2
  • 6
18
votes
4 answers

Automatically re-indenting elisp code when adding or removing code before an indented block

Say I have a elisp code like: (+ 2 3▮(+ 3 4)) Is there a way to automatically re-indent the sexp after the cursor, when I add or remove symbols? So after pressing SPC 4 SPC, I would automatically get: (+ 2 3 4 ▮(+ 3 4)) I…
Maciej Goszczycki
  • 1,777
  • 13
  • 18
17
votes
1 answer

How to indent items in LaTeX/AUCTeX itemize environments?

Q: how can I get "proper" indentation of LaTeX itemize environments in auctex? Here's where I'd like to be with an item in an itemize environment: \item line is indented two spaces relative to the beginning of the environment continuation lines in…
Dan
  • 32,584
  • 6
  • 98
  • 168
17
votes
1 answer

Correct indentation for wrapped lines

I have the following wrapped text, especially when you use a lot of windows: I'm wondering if the indentation of wrapped text could be changed like in Vim: When figuring out, it seems the AutoFillMode is responsible for this. I was hoping this…
ReneFroger
  • 3,855
  • 22
  • 63
16
votes
3 answers

Set indentation for shell script function

I am trying to set the number of spaces per indent for starting a new function in sh-mode (bash sub-mode). I have tried setting: '(sh-basic-offset 2) '(sh-indentation 2) '(smie-indent-basic 2) (as shown in custom-set-variables in .emacs) and some…
Robin Green
  • 949
  • 7
  • 16
15
votes
1 answer

How to set indent to 4 spaces in nxml-mode?

I wanted to indent my XML files with 4 spaces. I tried to google it, and found this and this one. But they seem pretty old and/or didn't help me. This post is great about how to pretty print XML files, but gives no hint how to set indent to a…
nephewtom
  • 2,219
  • 17
  • 29
15
votes
3 answers

Navigate by indentation

I want to navigate between the lines of a file based on indentation. The file is structured by indentation: a line that's more indented than the previous line is a child of the previous line, a line that has the same indentation as the previous line…
14
votes
5 answers

How to auto-format the source code block in org-mode

When I'm using org-mode to take notes about a book, sometimes I'll copy/paste some code snippets into the note file. After pasting it, I'll 1. `C-c '` to call `org-edit-special` 2. `C-x h` to mark all the source code 3. `TAB` to format it Is there…
CodyChan
  • 2,599
  • 1
  • 19
  • 33
13
votes
4 answers

How to customize org-mode indentation?

this question actually arises because I like to use non-monospaced fonts, (Sabon, Minion, Garamond, etc.) This cause a problem when use org-indent-mode, since the text under the headlines are now not aligned with the headlines. Example: The font is…
Alex
  • 415
  • 5
  • 12
13
votes
1 answer

Coloring indentation levels

Consider the following two snapshots: The first below is coming from Emacs on Python mode (with Jedi & Elpy) This second one below comes from manually photoshopping the previous one to make it easier to distinguish between so many indentation…
Amelio Vazquez-Reina
  • 5,157
  • 4
  • 32
  • 47
1
2 3
35 36