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.

542 questions
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,267
  • 1
  • 16
  • 17
25
votes
5 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,336
  • 16
  • 16
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,877
  • 14
  • 18
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,850
  • 23
  • 66
13
votes
1 answer

View code with different indentation than saved to disk

I work on some projects with indentation styles that I find really irritating. I'd like to view the code with a certain indentation style, but always save to disk with the prescribed indentation style. Specifically, I like emacs default style of…
Spacemoose
  • 897
  • 1
  • 8
  • 18
6
votes
1 answer

Indentation of list constants

Emacs' indentation of Emacs lisp code is really great, except for one thing: (defconst one-to-ten '(one two three four five six seven eight nine ten)) Is this actually the preferred way to…
Clément
  • 3,985
  • 1
  • 23
  • 39
6
votes
4 answers

Confusion by the usage of indent-tabs-mode nil

I use (setq-default indent-tabs-mode nil) in my init file so to avoid using TABs but when I write some files (like C++ files) then it allows me to insert TABs if I am in an if-statement for example. Why is that happening? Also I thought initially…
Adam
  • 2,447
  • 2
  • 22
  • 40
5
votes
2 answers

Indentation of newlines

I am writing source code and a lot of times I need to press Enter and have the newline indented with 4 spaces more than the previous. As I don't want to do it always, I would like to be able to use C-RET to achieve this. While searching I found C-j…
Adam
  • 2,447
  • 2
  • 22
  • 40
5
votes
1 answer

Indention and tabs in fundamental mode

How can I control the indentation of a line in a plain text file? In fundamental-mode, when you begin to type a line (call it Line A) after a previous line by hitting return, the line will automatically inherit the indent of the previous line. When…
Tim
  • 5,007
  • 7
  • 32
  • 61
4
votes
0 answers

Tuareg mode indentation after the first open clause

I'm working through the Real World OCaml book. Based on the installation instructions, I installed tuareg-mode for editing OCaml code. It is version 2.0.9, which appears to be the latest version. The corresponding code in my init.el looks like: …
InFreefall
  • 141
  • 1
4
votes
3 answers

Dumb indentation

I want to force Emacs to do (quasi-)dumb indentation à la Eclipse. By this I mean the following: If the point is at the beginning of a line and I press tab, force shift the line 2 spaces to the right. If a region is selected and I press tab, force…
NVaughan
  • 1,481
  • 12
  • 27
4
votes
1 answer

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 definition like so: - name: install packages Adding the…
elethan
  • 4,825
  • 3
  • 30
  • 56
4
votes
2 answers

Unnecessary indents when copying some text into a buffer

When I copy some text into a buffer in Fundamental mode, from some website opened in Firefox, there are always some unnecessary indents. For example, from https://github.com/hakimel/reveal.js/, I selected and copied some text by Ctrl+c, and pasted…
Tim
  • 5,007
  • 7
  • 32
  • 61
3
votes
1 answer

Return heavily indents previous line

If I'm editing certain filetypes then sometimes when I hit return at the end of a line the cursor will move to the next line and the previous line will suddenly be heavily indented. This behavior seems to happen in a few different filetypes under…
Praxeolitic
  • 387
  • 2
  • 9
3
votes
1 answer

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 Z.X.Y (a, b, c) After typing…
Daniil Iaitskov
  • 205
  • 1
  • 8
1
2 3 4 5