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
18 views

indent-buffer At top level

Not really sure why this has stopped working When I run the command indent-buffer ..it just says At top level Same if I mark the whole buffer and run indent-region. Any way to debug this?;)
1 vote
0 answers
7 views

Python-mode Multi-line Conditional Indentation

Given the following somewhat silly Python code with a multi-line condition: if ("VALUE" in my_uncessarily_long_dictionary and some_other_long_condition_case): do_something() else: ...
  • 1,219
0 votes
0 answers
18 views

How to always use tabs when pressing the tab key?

I use an indentation sensitive language (imba) and I need to always use tabs. I'm using doom emacs and I'm also writing a wip major mode for Imba. But I press tab and it adds indentation using tabs (a ...
0 votes
1 answer
29 views

How to fix indentation of items below header 3 in org mode?

In org mode, when I do a header 1 or 2, the bullets beneath it snaps to align under the header. But bullets do not indent under for header 3. How do I edit this?
0 votes
1 answer
19 views

Org mode recursive section indentation

I would like to add a "super-heading" with recursive section indentation. By that I mean that I want to transform the content: * Fruits ** Durian ** Jackfruit ** Lychee to become * Produce *...
  • 205
0 votes
0 answers
19 views

How to indent curly braces {} in php-mode?

I'm using Doom Emacs with emacs version 28.2. I want to use emacs to write all of my php code using php-mode and all the utilities it brings but the indentation is not what I want. When I type ENTER ...
0 votes
0 answers
15 views

How to set brace style for empty function in Doom emacs?

When defining an empty function Doom emacs makes it such that the function automatically looks like this: // after inserting braces void my_func() {} // after pressing enter void my_func() { } /...
  • 95
0 votes
0 answers
11 views

how to get correct indentation in haskell-mode in spacemacs

When in haskell mode indentation is not working quite how I expect it to. When pressing enter in an "else" statement the cursor goes to the beginning of the line instead of the correct one ...
0 votes
1 answer
21 views

Emacs 28.1: Bash Shell Script Indenting does not recognize if [....];then

Since upgrade to Emacs 28.1, I have noted an annoy change in shell-script mode auto-formatting. I would like to recover the old behavior Before, if I entered if [ "$x" = "" ];then ...
  • 1
0 votes
0 answers
10 views

Get auto-indentation with newline-and-indent in Scheme REPL

My Scheme REPL is not auto-indenting; I eventually tried just <M-x> newline-and-indent from within a define block in the REPL, and there's no indentation. It works fine in SLIME and .lisp files. ...
0 votes
0 answers
21 views

Indenting inside a sexp "as is the containiing sexp were not there"

I need to customize lisp-indent-function for a particular type of functions in such a way that it would indent lines "as if the function call were not there"; for instance say that I want to ...
  • 85
0 votes
0 answers
67 views

How to instruct AUCTeX to ignore a specific character when indenting?

I'm writing a document with AUCTeX using the songs package. It all works well, but it requires to input chords like in the sequence \[La]. The problem is, AUCTeX ignores the first bracket (since it is ...
0 votes
1 answer
64 views

How can I prevent adding a TAB if inner block is already aligned, in `pine-script-mode`?

I am using pine-script-mode with a 4 space TAB. Here is an inner block of an if statement that is already aligned. How can I prevent adding a TAB char (or 4 space chars) when I press TAB? pine file: ...
  • 1,090
1 vote
1 answer
37 views

delete backwards until indentation

In my config I have (bind-keys* ("C-<backspace>" . (lambda () (interactive) (kill-line 0)))) which deletes the entire line backwards until column position 0. I would like to only ...
  • 543
0 votes
1 answer
25 views

cant indent with tabs

In my ~/.emacs I have among other things, the following, at the end: (define-key c++-mode-map (kbd "<C-tab>") 'company-irony) (define-key c++-mode-map (kbd "<tab>") '...
  • 133
0 votes
0 answers
6 views

Dedentation in haskell-mode

Many Haskell coders like to dedent certain keywords so that their code looks like this: main :: IO () main = do opts <- execParser optsParser putStrLn (concat ["Hello, ", ...
1 vote
1 answer
82 views

Inconsistent indentation in org-mode

I am an Emacs (and Stack Exchange) newbie, but I think I did my reading. I don't know why Emacs shows an inconsistent indentation in documents longer than one screen. My relevant settings are: (setq ...
0 votes
1 answer
35 views

Babel C++ blocks have incorrect indentation

When using a C++ source block in org-mode, the indentation doesn't match that of the C++ major mode. Viewing the source block in the org file: Viewing the same code in a C++ mode buffer or using org-...
  • 1
0 votes
2 answers
50 views

How to remove margin space from multiple paragraphs simultaneously in orgmode

Sometimes when copypasting from the web, orgmode retains the margin in the text. Is there a command in Emacs to remove it? I know of cycle-spacing, but this is slow as it works line by line. Is there ...
  • 145
1 vote
1 answer
171 views

How to make tab-width 4 space in pine-script-mode?

I am using pine-script-mode for TradingView Pine script. When I follow https://emacs.stackexchange.com/a/17565/18414 I have applied: (defun my-custom-settings-fn () (setq indent-tabs-mode nil) (...
  • 1,090
0 votes
1 answer
56 views

How to set up K&R everywhere (1TBS) brace style in cc-mode?

I'd like Emacs to follow this indentation style: struct Foo { void bar() { for (int i=0; i<10; i++) { if (condition) { // code // code ...
  • 26
1 vote
1 answer
68 views

Use spaces for indentation in Protocol-Buffers mode

Protocol-Buffers mode binds c-indent-line-or-region to the TAB key. Since one of my projects uses 4 spaces for .proto file indentation, I've tried customizing indent-tabs-mode to nil, and tab-width ...
  • 111
0 votes
0 answers
20 views

Convert a Double Space Indentation to Tab (width - 4) Indentation

I am facing this problem which on the face of it should be easy to solve but isn't. this is my .editorconf: root = true [*] indent_style = tab tab_width = 4 end_of_line = lf charset = utf-8 ...
1 vote
1 answer
144 views

indent-region does not respect my c-mode style

This is my C style: (defconst mira-c-style '((c-basic-offset . 4) (indent-tabs-mode . nil) (tab-width . 7) (c-comment-only-line-offset . (0 . 0)) (c-lineup-C-comments . 0) (c-...
  • 479
1 vote
2 answers
36 views

format old file to org-indent-mode

I want to convert file created without (org-indent-mode) to (org-indent-mode) format. Mostly it's additional 2,3,4 spaces. I was trying to fix it with string-replace. But maybe somebody have better ...
  • 441
0 votes
1 answer
32 views

Can't set indentation to 4 spaces because hook is not called

I'm trying to set the indentation in C++ files to be 4 spaces. To achieve this I have the following config: (setq-default indent-tabs-mode nil) (setq-default tab-width 4) (defun init-c-cpp () (setq ...
  • 103
0 votes
1 answer
21 views

Ruby: Incorrect indentation for `indented_internal_methods`

Given a buffer with some Ruby code: class Foo protected def respond_to_query query; end end When I mark it and run indent-region (C-x h, C-M-\) it stays as is and my rubocop complains: Use 2 (...
1 vote
1 answer
30 views

Switch Cases's code block doesn't get indented in JavaScript mode

I'm having trouble with the indentation of the cases's code-blocks in my switch statements it looks like this: switch(var) { case "case1": case's code line 1; case's code line 2; ...
0 votes
1 answer
58 views

Comment continuation in block comments

It used to work in c-mode, but I cannot get it back, and now I miss it in rustic, too: If in a block comment, I want Emacs to insert "\n * " after I hit return: /** *<-- [if I hit return ...
  • 101
0 votes
1 answer
52 views

Indentation in HEREDOC

I'm looking for a way to make the indentation in HEREDOCs better. In my case, it's specifically in Ruby, but maybe this is a general question. Basically, I have the following situation: in our tests, ...
  • 501
0 votes
1 answer
106 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 ...
0 votes
1 answer
103 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 ...
2 votes
1 answer
39 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 ...
  • 455
2 votes
2 answers
56 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 ...
  • 173
0 votes
0 answers
17 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 ...
0 votes
0 answers
36 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
35 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 ...
0 votes
0 answers
39 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-...
2 votes
1 answer
197 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 ...
0 votes
0 answers
92 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 ...
0 votes
1 answer
221 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
2 answers
29 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 ...
1 vote
0 answers
282 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 ...
0 votes
1 answer
126 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 { ...
  • 23
5 votes
1 answer
914 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.
  • 230
1 vote
1 answer
91 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
42 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 ...
  • 101
0 votes
0 answers
33 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
1 answer
48 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 ...
0 votes
1 answer
33 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 ...

1
2 3 4 5
11