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 ...
user avatar
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 ...
user avatar
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 ...
user avatar
  • 87
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 ...
user avatar
  • 143
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 ...
user avatar
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 ...
user avatar
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 ...
user avatar
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-...
user avatar
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 ...
user avatar
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 ...
user avatar
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 ...
user avatar
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 ...
user avatar
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 ...
user avatar
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 ...
user avatar
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 { ...
user avatar
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.
user avatar
  • 130
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 ...
user avatar
  • 130
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....
user avatar
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 ...
user avatar
  • 101
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 ...
user avatar
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 ...
user avatar
  • 607
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 ...
user avatar
0 votes
1 answer
39 views

TAB should indent at start of line and advance to tab stop otherwise

More precisely, I would like TAB to indent the current line when there are 0 or more whitespace characters between the start of line and the point and to advance to the next tab stop otherwise. I used ...
user avatar
0 votes
1 answer
26 views

Why having a system loaded makes any difference for indentation?

I am using Common Lisp, SBCL, Emacs, and Slime. During a code review, a co-worker mentioned that the indentation of an s-expression was wrong. Usually, I just use indent-sexp(bounded to C-M-q) to fix ...
user avatar
0 votes
1 answer
25 views

how to fix / workaround wonky emacs auto-indenting of some C++

See the below. I have two definitions of a floating point array. The latter is valid with C++11. The first one is auto indented in a sane fashion. The second one looks like emacs just doesn't know ...
user avatar
  • 345
0 votes
0 answers
3 views

c sharp mode extra indentation of braces for functions located inside class

Emacs 26.3, Ubuntu Linux. In c sharp mode when a function is not inside class, the brackets are not indented: public static void Main(string[] args) { System.Console.WriteLine("Hello"); }...
user avatar
  • 845
0 votes
0 answers
32 views

How to fix auto-indentation of previous line when entering newline?

Suppose I have this indentation: with {:ok, _} <- Foo.bar(x, %{ baz: "foo" }),~ true <- 1 < 2 do # [...] end and ~ marks where's my cursor. If I then ...
user avatar
  • 101
1 vote
1 answer
70 views

Change indent for function calls in Emacs Lisp?

While writing the question I found a viable workaround solution for myself, so I am posting it as Q&A. I am leaving the question open, because my workaround does not allow to set the amount by ...
user avatar
  • 1,481
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 ...
user avatar
0 votes
0 answers
13 views

smart-shift: exit 'smart shift keychord'

I use https://github.com/hbin/smart-shift. I bound keys to do smart-shift-left / right But when I press them I stay in 'smart shift keychord' mode and must press C-g to exit. I wonder how to exit ...
user avatar
  • 127
4 votes
1 answer
471 views

Is there indentation in org src blocks?

I'm going kinda crazy trying to understand what's going on here... Asked this question on the r/emacs subreddit so apologies if any of you are seeing this again. Do org blocks allow TAB indentation ...
user avatar
0 votes
0 answers
12 views

How to make python-mode follow indentation of first line for an entire block

I want python-mode to follow the indentation of the first line. I want to avoid having to issue C-c <, C-c >. If I have this block (source): def fib(n): # write Fibonacci series up to n &...
user avatar
0 votes
0 answers
48 views

Why emacs makes weird indents in arrays

Often, emacs makes weird indentation in arrays: first line indented properly, but next lines are indented twice. This behaviour found mostly in php (with web-mode): array( array( 'name' => 'Add'...
user avatar
  • 1
1 vote
1 answer
23 views

Turning off indentation for goto labels

I'm using the ellemtel style for my C code. This mode indents goto labels like this: void f(int x) { if (x) { goto LABEL0; } else { goto LABEL1; } LABEL0: printf("x is zero\n&...
user avatar
  • 113
1 vote
0 answers
19 views

Customized c-mode indentation style in Emacs 27.2

I would like to produce c code in the following format: char *ft_strdup(const char *s1) { char *h; size_t len; ... } Where I can tab after the type of the function signature and ...
user avatar
0 votes
1 answer
47 views

Why is code indentation in the current codebase of Emacs so difficult to read?

I'm looking at the codebase of Emacs (for example gnus codebase) and see that the code indentation style is so weird. For example, here is source code of the functions gnus-sort-threads-recursive in ...
user avatar
  • 259
0 votes
1 answer
192 views

yaml: How to set indentation width?

I'm new to editing yaml with emacs. I currently use yaml-mode 20210808.1122 installed like so : (use-package yaml-mode) (add-to-list 'auto-mode-alist '("\\.yml\\'" . yaml-mode)) I would ...
user avatar
  • 127
0 votes
1 answer
78 views

Org mode how to apply 4 spaces for tab without initial indent inside source-code-block?

On this example, cursor is at beginning of if when I press tab 2 space indent is added beginning of if block, which is aligned. ** TODO help | ** TODO help #+begin_src python | #+...
user avatar
  • 1,036
0 votes
0 answers
11 views

Strange flush left C-code formatting in Emacs 24.3 of SLES 12 SP5

I see some odd Emacs behavior in C-mode recently. I suspect that the change happened either when switching from SLES 12 SP4 to SLES12 SP5 (both have Emacs 24.3), or when switching from SLES 11 SP4 (...
user avatar
  • 153
0 votes
0 answers
28 views

Overriding semicolon indentation rules from cc-mode for structs

Context: I've a language mode that derives from cc-mode. The language is quite similar to C++, however one difference is that semicolon doesn't follow a struct definition. For example struct S { uint ...
user avatar
  • 389
0 votes
0 answers
52 views

How to disable babel block indentation?

Is it possible to disable the indentation of new babel source blocks? I played with electric-indent-local-mode and org-src-preserve-indentation without success. Current output: * aa ** bb #+...
user avatar
  • 203
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 ...
user avatar
  • 1,481
0 votes
1 answer
39 views

Is there a way to automatically indent a parenthesis in Slime REPL after pressing `C-m o`?

I am using Slime, Paredit, and SBCL to code in Common Lisp. While editing a .lisp file, suppose I have this code: (dotimes (i 4)) I will represent the cursor (point) as -!-. Having the cursor in this ...
user avatar
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:...
user avatar
  • 1,036
2 votes
0 answers
230 views

Behavior of indentation in Org

I use Emacs 27.2 and Org 9.4.6. Since a very recent update of Org, I noticed a strange change in the behavior of indentation. In my init file, I have set the variable org-adapt-indentation to '...
user avatar
0 votes
1 answer
34 views

Why Emacs creates multiples whitespaces after I create a comment and jump to a new line?

I am using Emacs, Paredit, Slime to work on Common Lisp (SBCL). When I create a comment such as: ; test It is placed as expected. But if I press return in order to create a new line below ;test this ...
user avatar
1 vote
1 answer
506 views

How to set the default indentation width globally?

By default Emacs uses tab instead of spaces for indentation, so I changed these 2 variables to change this behavior, (setq-default indent-tabs-mode nil) ;; Disable indent with tabs (setq ...
user avatar
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 ...
user avatar
3 votes
1 answer
112 views

How to get the following indentation style in c?

I would like to have the following behavior: int main(){ to result in: int main(){ | } Where pipe is the cursor, and I DON'T have to press RETURN key after '{'. I have already achieved the ...
user avatar
0 votes
0 answers
41 views

incorrect c++ enum indentation in emacs 26.x

My emacs 26.3 insists on a very strange enum indentation even when started with --no-init-file --no-site-file class A { public: enum EnumWithLongName { val0, ...
user avatar
  • 111

1
2 3 4 5
10