2022 Developer Survey is open! Take survey.

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
0 answers
11 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
37 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
42 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
39 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
20 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
67 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
31 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
114 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
  • 131
0 votes
0 answers
12 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
  • 131
1 vote
1 answer
30 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
25 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
19 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
16 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
37 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
25 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
24 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
31 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
66 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
4 votes
1 answer
220 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
393 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
47 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
21 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
164 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
74 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,112
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
27 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
51 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
77 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,112
1 vote
0 answers
184 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
33 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
419 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
107 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
107 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
40 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
2 votes
2 answers
97 views

How to fix indentation for `dash.el` threading macros (e.g. `->>`)

As I write more Elisp, I find myself using the threading macro increasingly often. However, since it is an imported, not a built-in one, the indentation is not like what I want it to be. For example, ...
user avatar
0 votes
0 answers
30 views

No PHP blade block syntax highlight or indentation

I am creating an app with Laravel using Emacs and I can't get Emacs to highlight syntax using web-mode in blade with neither @php @endphp blocks or using <?php ?> blocks. I saw this question ...
user avatar
1 vote
2 answers
86 views

`dtrt-indent-mode` erroneously uses Tab characters

Here is an example file (/tmp/asdf.sh), for which I want dtrt-indent-mode to do the right thing. #! /usr/bin/env bash function asdf() { printf "asASDFASDF" echo "1234" } ...
user avatar
  • 387
0 votes
1 answer
907 views

Indentation in Org Mode Source Block with Return

I have a weird behavior in org-mode. When I create a source block, pressing RET indents the current and all previous lines with 2 spaces, resulting in something like #+begin_src bash :results output ...
user avatar
1 vote
1 answer
71 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. ...
user avatar
  • 111
2 votes
1 answer
155 views

How to change CSS files to indent to 2 spaces?

I have only installed emacs straight out of the box. I have not installed anything else: GNU Emacs 26.3 Copyright (C) 2019 Free Software Foundation, Inc. GNU Emacs comes with ABSOLUTELY NO WARRANTY. ...
user avatar
1 vote
1 answer
88 views

How to disable auto indentation in asm-mode

When programming in extended assembler (using asm-mode), auto indentation insists on indenting compiler directives, such as #define, #if and #endif, how can I disable this? Emacs version: 0.300.0@26....
user avatar
  • 104

1
2 3 4 5
10