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.

Filter by
Sorted by
Tagged with
0 votes
1 answer
19 views

Is it possible to use LSP for font-lock or indentation?

I'm writing C++ and running into problems with font-lock-mode often getting confused by more obscure language features (e.g., operator""_ud). I also find that indentation doesn't work very ...
1 vote
1 answer
112 views

Maintaining consistent visual fill column under `org-indent-mode`

How can one enable org-indent-mode (or otherwise indent content to Org headings) while still maintaining a consistent visual fill column?
0 votes
1 answer
48 views

Why emacs editor changes indent automatically when copy a context into it?

I'm using web-mode package. The source(.tsx file) in Emacs before: import React from "react"; export default { ... args: { name: "", // Here }, decorators, }; The ...
0 votes
2 answers
38 views

Can emacs handle bash extglob case patterns properly?

This question is in two parts: How to cause emacs linter to recognize an extglob expression as an ability instead of a syntax error? How to cause emacs indenter to recognize an extglob expression as ...
0 votes
1 answer
18 views

Changing indent-tabs-mode and electric-indent-mode in a buffer

I want to change indent-tabs-mode and electric-indent-mode to nil. There exist three possibilities setq-default setq-local setq I think setq-default only changes the behaviour for major modes where ...
1 vote
1 answer
76 views

Why is electric-indent-mode adding extra indentation after pressing return twice in org source blocks?

When I try to write code in source block in Org mode, pressing return once acts as expected while hitting it a second time increases the indentation to two levels if it's currently less than that. ...
0 votes
0 answers
11 views

Fix inconsistent background coloring of org-mode blocks with wrapped lines

When having a source block in a .org document, with line wrapping enabled, the continuation of an indented, long line, that is wrapped to the next line is naturally also indented. The problem is, that ...
2 votes
1 answer
3k 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
1 answer
100 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
0 answers
23 views

How to make curly braces auto indent in sh-mode

If typed in sh-mode the closing brace is not auto-indented: function() { } If typed in c-mode the closing brace is auto-indented when inserted: function() { } The exact keystrokes are: f u n c t ...
2 votes
0 answers
23 views

org-mode still indents content while I try to set it up not to

I set org-adapt-indentation to headline-data When I select a region under a headline (separated by a blank line) and press TAB, the paragraph gets indented at the same level as the headline title, as ...
1 vote
1 answer
133 views

Change `standard-indent` for 1 specific major mode

I author web apps with the web-mode in GNU Emacs, and I use 2 spaces for indentation. After I examined the web-mode source, I found out that the mode defaults to the standard-indent variable, which in ...
0 votes
1 answer
64 views

Any Elisp equivalent of Python's inspect.cleandoc?

When working with code generation, Python's inspect.cleandoc is quite useful, as it allows to write inline code in a multi-line string and then automatically adjust the indentation. # -- Input: def ...
3 votes
1 answer
93 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
0 answers
14 views

Why is paredit-reindent-defun not working in my cider-repl?

I have been using the command paredit-reindent-defun (M-q) a lot in Slime. In a situation such as having this: ; SLIME 2.26.1 CL-USER> (defn multi-arity ;; 3-arity arguments and body ([first-...
0 votes
1 answer
52 views

In Doom Emacs, when cursor is highlighting a line, it indents a few pixels in. How to turn off the indent and just do line highlighting?

I can't find a setting to turn off that small pixel indentation when cursor is highlighting the line you're on. It makes it hard to try to type text to align when the line itself is indented a few ...
0 votes
1 answer
66 views

How can I insert some multiline text that respects the indentation at which it is inserted?

I have a function that reads a link from the clipboard and generates a metadata-ful markdown link from it, and inserts it: (defun night/unt () (interactive) (let* ((link (current-kill 0)) ...
8 votes
1 answer
261 views

indent cl-loop to respect `if else` statements

I have a hard time writing and reading cl-loops with they way they're indented by default as I can't easily tell what the control flow is: (cl-loop for x below 10 if (cl-oddp x) ...
0 votes
1 answer
22 views

How to make indentation follow beginning of text in list

I want electric-indent or more generally, hitting ENT, to indent the new line to the beginning of text. I'd like this to work with auto-fill as well. Before: 1. This is a long list item that I'll wrap ...
2 votes
1 answer
38 views

Strange autoindentation in org mode source blocks

I try to use org-mode as a replacement for jupyter notebook, and I was faced with a problem: when I edit a python src block, newlines don't indent properly, so I have to press space 4 times after ...
3 votes
1 answer
242 views

How to set web-mode to use single-line comment style instead of multi-line for JavaScript

When commenting C-style code like C++, JavaScript etc., I use single-line comments to be able to uncomment a previously commented region selectively, i.e // This // is // a single-line style // ...
6 votes
1 answer
273 views

How can I make python-mode correctly indent python's match statement?

Python 3.10 added a match statement. When I try and type one in emacs 27.2, it does not indent it correctly, presumably because it does not yet have support for it. How do I get python-mode to ...
9 votes
1 answer
229 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(...
7 votes
2 answers
781 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
2 answers
608 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
0 answers
45 views

Indenting of prose in org-mode looks different when exporting

I use Emacs and Org Mode for writing prose. The problem is with the way Org interprets the concept of paragraph and the way Org and Emacs handle indentation in the beginning of paragraphs. This is ...
1 vote
3 answers
391 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 ...
1 vote
1 answer
128 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
0 answers
87 views

Changes in python.el do not take place in python-mode

I'm facing the same problem as OP in this question: How can I make python-mode correctly indent python's match statement?. A quote from the OP: "Python 3.10 added a match statement. When I ...
9 votes
3 answers
576 views

Indentation in square brackets

Yet another question about indentation in AUCTeX... I would like to be able to indent content inside square brackets [...]. It would be useful for tikz option lists, for example, or trees drawn using ...
0 votes
1 answer
402 views

Javascript mode mixes tabs and spaces for indent

My javascript mode indents with a mix of tabs and spaces. I'm ok with the mix if spaces are used for cosmetic alignment, but this is just wrong: First level of indentation is spaces, second is tab, ...
0 votes
1 answer
30 views

Auto-indentation for Meteor/spacebars

How do I get Emacs to auto-indent Spacebars blocks when coding with Meteor? Right now, Emacs automatically does this: {{#each player}} {{name}} {{/each}} instead of this: {{#each player}} {{name}}...
3 votes
1 answer
447 views

How do I keep the indentation on org-babel-tangle?

In literate programming, I often like to write my code in small snippets and then export them all at once via org-babel-tangle. This works great for non-indentation sensitive code (especially with ...
1 vote
1 answer
32 views

How to keep a multi-line nested bullet list indentation (and bullets if possible) when pasting from Google Docs to emacs

I copy a nested list like this: - foo - bar - foo - bar from Google Docs to emacs, but the bullet points vanish and the indentation as well. The same happens in the normal Linux text editor....
0 votes
0 answers
8 views

Disable electric reindent for specific lines

I am writing indentation code for a custom language. I have a working implementation of indent-line-function. However, I need to change the behavior of electric indent, depending on the content of the ...
0 votes
1 answer
32 views

Disabling auto identation when saving a file

I'm using Doom Emacs (pretty much vanilla with a few packages) and whenever I save a file, Emacs automatically changes the indentation. For example, if I'm editing a C++ file like this: FoamFile { ...
2 votes
0 answers
231 views

adaptive-wrap-prefix-mode behavior is different/inconsistent inside a buffer

in org-mode I have adaptive-wrap-prefix-mode on. The indentation though has a inconsistent behavior. I have already tried to toggle visual-line-mode and word wrap but the sometimes correct and ...
2 votes
1 answer
114 views

New line and indent without electric mode

I have come to hate the inconsistency of the electric indent mode and I haven't much of a clue about how it works anyways, so I've disabled it and am trying to get the desired behavior from scratch. I ...
0 votes
1 answer
168 views

Why does org-mode not indent content under headings when I press tab?

In a buffer like this: * Heading ** Sub-heading content| pressing <tab> should result in this: * Heading ** Sub-heading content| Instead, nothing happens.
0 votes
0 answers
15 views

How do I make org-indent-mode put me at the right indent when I make a new line?

This is the current situation: * Heading ** Sub-heading *** Sub-headings content1<return> | I entered that text and now want to add a second line to the content by pressing return. My ...
6 votes
2 answers
851 views

Whitespace-mode tab mark disturb my indentation

I encounter this issue when i set whitespace-style to (face tabs trailing tab-mark) and turn on whitespace-mode. When whitespace-mode is turned off, everything looks well: When whitespace-mode is ...
6 votes
1 answer
945 views

Display tab characters as arrows of varying length

I would like to make tab characters ("\t") display as arrows of varying length, just like in editors such as Notepad++, gedit, Geany, etc. Here is an example with tab width set to 4 and space ...
3 votes
1 answer
39 views

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 ...
2 votes
1 answer
2k views

Variable-pitch face breaking indentation in org mode

I want to use a variable pitch face when using org mode (for composing articles, prose, etc.) The emacs wiki suggested using buffer face mode with a hook to set the face for org mode buffers: ;; Use ...
0 votes
0 answers
30 views

How to indent Org Babel list output with multiline text correctly?

I'm using Babel to generate some text in an Org file. I'm using :results value list header switch described here to format the output in Org's list structure. It doesn't quite format multiline text ...
4 votes
1 answer
170 views

How to tell Emacs to keep indentation in algorithmic environment?

I frequently find myself typesetting algorithms, and I choose the algorithmicx/algpseudocode package for that. I like the package, it is simple to use and has everything I typically need. The problem ...
0 votes
0 answers
27 views

indent-region inconsistent with existing code that's indented more than python-indent-offset

Say I have an existing, simple block of code that uses an indent width of 4, as such def incDictValue(d, k): if not k in d: d[k] = 1 else: d[k] += 1 return and setup ...
0 votes
0 answers
18 views

Indent Headers in outline-minor-mode

In org mode, we can use the org-indent-mode hook to indent each header level, making a document with an outline more readable. However, with outline-minor-mode, we the org-indent hook doesn't seem to ...
0 votes
0 answers
20 views

Disable indentation in sh babel src block on hitting `RET`

I've implemented many snippets to my init.el (bottom of this post) to no avail. Any other ideas to have RET in an sh block returning the cursor to a new line's beginning instead of giving: Setting up ...
2 votes
1 answer
80 views

How to define global key binding for `C-c >` and `C-c <` using `defhydra`

I am trying to apply following solutions's key binding to overwrite all mode's key bindings for C-c > and C-c <. From the answer for Can we do C-c > and > and > to continue indentation:...

1
2 3 4 5
10