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)
nephewtom's user avatar
  • 2,249
16 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's user avatar
  • 32.7k
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 ...
Tyler's user avatar
  • 21.9k
11 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 ...
Robin Green's user avatar
10 votes
Accepted

How to indent without the two extra spaces at the beginning of code blocks in org mode?

Try to customize org-edit-src-content-indentation. I think by default it is set to 2. I think this is what controls that behavior. However, if you put (setq org-src-preserve-indentation t) in your ...
elethan's user avatar
  • 4,775
10 votes
Accepted

no html/jsx indentation in jsx-mode

This is a known issue and as of now, it has not been fixed. I've decided to forego jsx-mode for this reason and just use web-mode. It has support for JSX and is better suited for mixed content files. ...
flooose's user avatar
  • 511
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 ...
Basil's user avatar
  • 12.2k
10 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 ...
Atemu's user avatar
  • 290
9 votes

no html/jsx indentation in jsx-mode

FYI for anyone else who comes across this issue, this is because this jsx-mode project is not made to edit Facebook's React JSX templates but rather this other compiled javascript language also called ...
Victor Quinn's user avatar
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 <...
ABu's user avatar
  • 280
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-...
Hebi Li's user avatar
  • 81
7 votes
Accepted

Trouble adjusting tab-width

The first line when enabling python-mode is (set (make-local-variable 'tab-width) 8). Because tab-width is a buffer-local variable, a new value would need to be set subsequent to the code above. The ...
lawlist's user avatar
  • 18.9k
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 ...
Christabella Irwanto's user avatar
7 votes
Accepted

Change the behaviour of RET (with electric indent) to only indent the new line, not the previous one

I think you'll get what you want with (setq-default electric-indent-inhibit t) This was meant as a variable for major-modes (rather than for users), but it should take care of your use-case as well.
Stefan's user avatar
  • 26.3k
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 ...
Rainer Joswig's user avatar
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 ...
simenheg's user avatar
  • 121
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 ...
Drew's user avatar
  • 76.4k
7 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 ...
Heikki's user avatar
  • 3,026
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 ...
Aquaactress's user avatar
  • 1,443
6 votes

Navigate by indentation

This feature exists in Emacs. Outline mode describes a document as containing heading lines with a level, and has facilities to move among levels. We can define every line as a heading line with a ...
Gilles 'SO- stop being evil''s user avatar
6 votes
Accepted

Weird indentation behavior in C++ mode

It's not weird; std: could be a label and until you type the second : it doesn't know otherwise. Edit: I forgot to mention, but you can customize c-default-style to choose a different indentation ...
db48x's user avatar
  • 16.8k
6 votes
Accepted

Python cycling through indentation

If you follow through the code of indent-for-tab-command, you'll see the indentation is actually done by a indent-line-function. In Python mode, this is python-indent-line-function. The help for this ...
Tyler's user avatar
  • 21.9k
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))) ...
Mohammed Sadiq's user avatar
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-...
jue's user avatar
  • 4,501
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 ...
Lorem Ipsum's user avatar
  • 4,407
6 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 ...
einfeyn496's user avatar
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-...
NickD's user avatar
  • 28.2k
5 votes
Accepted

How to add four spaces selected region

I think indent-rigidly (C-x TAB or C-x C-i, see footnote) can help you. indent-rigidly is an interactive compiled Lisp function in `indent.el'. It is bound to C-x TAB. (indent-rigidly ...
YoungFrog's user avatar
  • 3,526

Only top scored, non community-wiki answers of a minimum length are eligible