23
votes
How to set indent to 4 spaces in nxml-mode?
I finally found it in this issue.
(setq nxml-child-indent 4 nxml-attribute-indent 4)
17
votes
Accepted
How to make emacs align and indent a bibtex entry?
When the cursor is somewhere in the entry, run the command bibtex-fill-entry (bound to C-c C-q), which will
align the fields. You may also want to set variable bibtex-align-at-equal-sign to a non nil ...
Dan♦
- 33.3k
15
votes
Accepted
Org-mode : disable indentation when promoting and demoting trees + subtrees
Set the variable org-adapt-indentation to nil. The default value is t, which means:
When this variable is set, Org assumes that you write outlines by
indenting text in each node to align with the ...
13
votes
Accepted
Set indentation for shell script function
Setting sh-basic-offset to the required indentation is what is needed - but what I didn't realise is, it's also necessary to close and reopen all shell script files before the customisation takes ...
11
votes
Accepted
Why does org-mode not indent content under headings when I press tab?
Org's indentation behaviour is controlled by the org-adapt-indentation variable. It can be set to three states:
t: Adapt indentation for all lines
headline-data: Adapt indentation for headline data ...
10
votes
Accepted
How to detect tabs or spaces in Emacs
By default I want all indentation (when I hit the tab key) to be 2 spaces.
This can be achieved for many modes with settings such as
(setq-default indent-tabs-mode nil
tab-stop-list ...
9
votes
Accepted
formatting constexpr if in c++-mode
UPDATE: That pretest version that I put down there in the original question (emacs-26.0.90.tar.gz) had a bug that cause certain infinity loops while parsing the buffer, specifically when using the <...
8
votes
Indentation in square brackets
Setting LaTeX-begin-regexp and LaTeX-end-regexp does not help here because inside LaTeX-indent-level-count it searches a backslash before checking the regexp.
I got it working by modifying TeX-brace-...
8
votes
Confusion about space and tab characters in Emacs
Like most things in emacs, the tabs policy is configurable. It sounds to me that you'd like to follow the most common apporach and use the tab key as an indentation tool and not have tab characters in ...
8
votes
Accepted
Emacs auto-indenting comments in an unhelpful manner
Unable to post this as a comment, but the indentation is likely part of one of the active modes (probably lisp-mode based on your description).
You can do M+x describe-modes to see which modes are ...
7
votes
How to customize org-mode indentation?
Somehow I couldn't get the other answers to work for my setup, but the fastest and easiest fix that worked for me was:
`M-x customize-face org-hide`
Then, just change the Font Family attribute to ...
7
votes
Accepted
Why does Emacs indent my Lisp LOOP construct weirdly?
You can use indentation provided by a SLIME contribution:
(require 'slime-cl-indent)
You may want to add that to the list slime-contribs- see Loading Contribs in the SLIME manual.
One can add it to ...
7
votes
Accepted
css-mode: use tabs and not spaces
The built-in CSS mode should support this just fine by giving indent-tabs-mode a non-nil value.
Note that spaces will still be used for padding if the number of indentation spaces isn't a multiple of ...
7
votes
Accepted
Emacs: indentation takes 4 spaces instead of 2
See this answer to a similar question. That answer doesn't answer that question, because it is about Ruby mode not respecting such code. But it likely does answer your similar question.
This is that ...
6
votes
How to indent keywords aligned?
Intro to calculate-lisp-indent
A better solution is to override the function calculate-lisp-indent. In brief, calculate-lisp-indent is a function that returns the column to which a line at point ...
6
votes
Customized c-offsets-alist override c-file-style in dir-locals
Instead of modifying c-offsets-alist, you can modify c-file-offsets whose purpose is to set offsets via file local variables.
A small example for a .dir-locals.el file:
((nil . ((fill-column . 80)))
...
6
votes
Accepted
Extra indentation for argument lists beginning on a new line
Set point on the line in question and press C-c C-s to call c-show-syntactic-information. This shows you which variable you need to set.
I set this to:
(c-offsets-alist . (
(arglist-intro . c-...
6
votes
Accepted
Can’t guess python-indent-offset - delete warning when local file variable
The error message is controlled by the python-indent-guess-indent-offset-verbose variable.
Since the variable is file-local, you should be able to disable it globally if you put the following in your ...
6
votes
Accepted
Emacs script to indent files from the command line
@glucas's answer is correct in its diagnosis, but has a minor problem (you want the 0th element of argv) and is incomplete. Here is a more complete example:
#!/usr/bin/env -S emacs --script
(find-...
5
votes
Accepted
How to make evil-mode tab key indent? (not re-indent based on context)
To have tab work as it does in VIM, use tab-to-tab-stop.
(define-key evil-insert-state-map (kbd "TAB") 'tab-to-tab-stop)
5
votes
Accepted
Fix indentation of LaTeX code without wrapping lines
If you only want to indent a region, you should call an indenting function, not a filling function that, as you guessed, is meant to break lines.
For example, you can use C-M-\ (M-x indent-region RET)...
5
votes
Accepted
Python mode indentation
I feel kind of ridiculous for not having seen this before, but I found the answer on the EmacsWiki: No Tabs page under the "Smart inference of indentation style" section. Putting that code in my init....
5
votes
Accepted
copy region without leading indentation
You basically just want to be calling indent-rigidly on a copy of the region. That will also deal nicely with indent-tabs-mode (which I think you'll find your version does not).
I'd suggest using a ...
5
votes
Accepted
Bash script is indented inconsistently
It is bug, fixed in version 26.1. As a workaround you can set both the variables sh-indentation and sh-basic-offset to 2.
5
votes
Confusion about space and tab characters in Emacs
To make tabs and spaces visible, you can enable whitespace-mode with M-x whitespace-mode RET or M-x global-whitespace-mode RET. Have a look at variable whitespace-style (e.g. M-x customize RET ...
5
votes
Keep text selection after indenting with evil
After using < or > to indent a selection in visual mode, you can use gv to restore the previous selection and do some other action. If you wish to selection to be restored automatically, you can ...
5
votes
Accepted
How to change shell-script-mode indentation not to use tabs?
Shell script mode does not have any setting that relates to using tabs vs spaces (at least as of Emacs 25.2). It obeys the default Emacs setting which is given by indent-tabs-mode and tab-width: 8 ...
5
votes
Accepted
Why is my Python indentation set to 8 locally by default?
The default is 4 spaces:
(defcustom python-indent-offset 4
"Default indentation offset for Python."
...
But python-mode guesses the spaces when opening a file and overwrites the default locally. ...
5
votes
Accepted
How to remove message `Indentation setup for shell type sh`
This is hardcoded into the function sh-set-shell which is called when sh-mode is invoked.
It's probably better to not touch that behaviour as it will also not display messages if it was not possible ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
indentation × 548org-mode × 52
python × 47
tabs × 42
c++ × 32
cc-mode × 26
whitespace × 23
web-mode × 22
auctex × 21
spacemacs × 19
c × 19
javascript × 19
latex × 18
major-mode × 17
formatting × 16
key-bindings × 14
evil × 14
comment × 14
electric-indent × 14
init-file × 10
org-babel × 9
smie × 9
align × 8
newlines × 8
java × 8