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
1answer
16 views

Need help with JavaScript `{` indentation

I'd need some guidance with adjusting my indentation settings for js-mode (JavaScript). It should basically look like C/C++'s Stroustrup mode. Most of it works as expected, however there are some ...
0
votes
0answers
8 views

how to differently indent different regions in the same buffer?

I have some scraps of xml and some scraps of scheme in the same buffer I'd like to indent the xml with svg-mode and scheme with the scheme-mode I know that org mode can do that but that is ...
1
vote
0answers
33 views

Why is js2-mode changing my indentation level when I type parenthesis

I'm getting started with some JS code in Spacemacs, and trying to get a good indentation level on my method chaining. The trouble is, once I've got an indentation to the place I want it, something (I'...
0
votes
0answers
5 views

web-mode turn off auto indent on yank

How to turn off auto indent on yank in web mode? As far as I understand, I must call remove-hook with the name of the hook and the function. But how too find them?
1
vote
1answer
23 views

Org ASCII export with indentation preserved

Open your EMACS -Q, enter org mode, and #+begin_src emacs-lisp (setf x '(a b c d e f)) #+end_src This is how it will be aligned after org-edit-special (C-c '). Now ...
0
votes
2answers
42 views

Emacs acting strangely with indentation

So I've recently come back to working with emacs again I mostly write JavaScript in particular React these days and I'm noticing some strange behaviour when trying to indent my code. it seems the ...
0
votes
1answer
34 views

Indentation of one-line zsh for loops

My EMACS (26.3) thinks the line after for i (`seq 1 10`) echo $i should be indented. Is this a bug?
1
vote
0answers
19 views

Generic method to customize indentation?

Is there some method to customize indentation in various Emacs modes, possibly on a per-project level? Projects can have widely different indentation styles, which can make automatic indentation ...
0
votes
1answer
29 views

How to make backspace respect tab-stops when there is only preceeding white-space?

When pressing backspace, it deletes a single character, however, I would like it to go back the the previous tab-stop level in the case there is only preceding white-space.
0
votes
0answers
23 views

Emacs text-mode as generic, 2-space-<TAB>, plaintext editor: Trouble disabling relative-indent in text-mode, or auto-triggering outline-mode

I need some help getting custom indentation behavior with my .emacs config. In emacs text-mode / Fundamental Mode, by default a tab will take me to the location of the top line's next word (non ...
0
votes
1answer
89 views

org-indent-mode prevents first-line paragraph indents

I'm a writer (non-programmer) using org-mode mainly for prose notes/planning and writing. I'm trying to enable first-line paragraph indents for text under Org headings. I discovered paragraph-indent-...
0
votes
2answers
35 views

Emacs occasionally using wrong indent in python

I have a bunch of python files (ie .py files), which I use Emacs to edit. However I keep having the issue where sometimes emacs will indent regions with 8 spaces instead of 4, and I can't figure out ...
2
votes
1answer
33 views

Pressing RET inserts unnecessary whitespace

My Emacs inserts whitespace on the next line if the current line starts with whitespace. IE a<RET> <--- whitespace This happens across modes (python, text-mode, fundamental-mode), ...
4
votes
1answer
54 views

change use-package indentation

I'd like to change use-package's indentation style to look more distinguishable, (more or less) similar like the following indentation style: (use-package foo :commands (gah) :init (setq f 1) ...
0
votes
0answers
12 views

How to get first nested parameter indented based on outermost function

I would like to get the following cc-mode indentation behavior (c-basic-offset is 4): outerFunction(innerFunction( parameter1, parameter2)); However I would like to maintain arglist aligned ...
1
vote
0answers
26 views

Markdown equivalent of `org-indent-mode`?

What's the simplest way of ensuring that the text below a headline in a Markdown file is aligned with the headline? In org-mode you can accomplish this by calling org-indent-mode. Is there a similar ...
0
votes
0answers
7 views

How to prevent indentation from depending on identifier length?

I noticed that a lot of Emacs indentation styles cause the indentation of one line to depend on the length of identifiers in the previous line, for example: void usage(char* name) { fprintf(...
1
vote
1answer
28 views

Adjusting indenting for lisp if statements

I am learning common lisp and am trying to follow the style guide suggested by lisp-lang.org. In this style guide is an if statement style that I think makes the code more readable: (if (cond) (...
2
votes
0answers
48 views

Indenting LaTeX code for \if \else \fi statements

This is related to this Emacs.SE question. I use the code from the answer: (setq LaTeX-begin-regexp "\\(?:begin\\|if@\\)\\b") (setq LaTeX-end-regexp "\\(?:end\\|else\\|fi\\)\\b") (defun LaTeX-indent-...
1
vote
1answer
41 views

auto-fill-mode without automatic indentation

Is it possible to prevent auto-fill-mode from automatically indenting new lines according to the previous? I would like new lines to begin at column 0 regardless of the previous line's indentation.
1
vote
0answers
32 views

Add whitespace as indentation with `indent-region`

When using indent-region, emacs will indent code and leave bank spaces untouched. It seems to me that the majority prefer to delete whitespace. However I prefer white space indented with the code. An ...
1
vote
1answer
34 views

Insert “indent” regardless of mode

When typing docstring in python-mode, I always have issue with indentation. If I am at this point (| is the cursor): def fn(): """ Args:|""" If I press Enter, the cursor will move right below ...
1
vote
1answer
29 views

customize js2-mode switch indentation

This is pretty simple but it's thwarting me: this is how a switch statement indents in js2-mode switch(letterGrade){ case "A+": value = 100 ; break; case "A": value = 97 ; break; ...
1
vote
1answer
49 views

Modifying ruby-mode indentation

Currently, ruby-mode in Emacs 27 indents the following snippets like this: expect(foo).to match( bar ) expect(foo).to \ match(bar) Is there a way to ...
0
votes
0answers
18 views

Python indent closing parentheses for multi-line function

I've discovered some reformatting with Black or Yapf: def responses(self, foo=SuperLongClassnameBar.FOOBAR ) -> List['Foobar']: Using emacs and elpy, it won't indent the closing ...
0
votes
0answers
29 views

electric-pair-mode screws indentation

I have some trouble with my emacs indentation. Since I have enabled electric-pair-mode my indentation is screwed when I use hanging braces. Example (| is my cursor): int main(int argc, char *argv[]) {...
0
votes
0answers
13 views

Customize indent of line-continuation in f90-mode?

In f90-mode, is it possible to make continuation lines indent to the opening parenthesis instead of by a fixed amount of columns, without having to rewrite f90-indent-line? For conformance with a ...
0
votes
2answers
34 views

How to “escape” a plain list / cannot outdent region

This is start from: * Up ** Foo - x Notice that the plain list under Foo is indented. This is what I want next: * Up ** Foo - x ** Bar But from - x, I don't know how to "escape" the plain ...
1
vote
0answers
53 views

Identation issues in python mode

almost everytime, I cope e.g. snippets from the web and paste it with M-w in a python buffer the indentation is all wrong. Sometimes slanted to the left, sometimes to the right. Often all of the ...
0
votes
0answers
19 views

Conf[Unix] not indenting configuration file

I am having trouble trying to configure the conf[Unix] mode to do indentation. I have a hook that indents the whole file when I save the file: (defun indent-hook() "Indent before saving." (indent-...
2
votes
2answers
29 views

Define key binding for a single mode (Fundamental)

In light that this may be a duplicate, but I did not find the answer to my question scouring this site. The default behavior of GNU Emacs appears to have electric-indent-mode enabled, which is fine ...
1
vote
2answers
42 views

(un)-Indenting text over a region

This in org mode. How do I get from 1 to 2 2 to 3 in as few keystrokes as possible? And, if possible, in reverse. I was hoping selecting Food's subtree and M-^ would do the job but what it does ...
0
votes
0answers
93 views

Bad indentation with tsx

I have a .tsx file and a function that returns some html. It starts like: return <div className=... Then at some point I have a component with many arguments so I have to split them vertically. I ...
1
vote
1answer
19 views

C-M-\ fails to indent Lisp code

I follow this tutorial. The code after selecting the region and <Tab> or equivalently C-M-\ in an org file: (setq trees '(pine fir oak maple) herbivores '(gazelle antelope zebra)) I would have ...
0
votes
1answer
84 views

How to disable syntactic indentation interactively in php-mode?

I discovered that in php-mode, syntactic indentation makes rigid indentation very slow when the marked region is big. When I disable syntactic indentation, rigid indentation is not slow anymore. So I ...
1
vote
0answers
18 views

How does SMIE mode determine what the parent of a token is?

I'm writing indentation rules for a custom mode using SMIE. I want to use smie-rule-parent-p to have different behavior for indenting an empty line depending on context, so inside my indentation ...
0
votes
1answer
28 views

Automatically fixing bad indentation (Scheme-Lisp)

Let's say I make this code with bad formatting: is there an emacs command that can automatically fix indentation? I know this question has been asked a few times before, but all the answers I've seen ...
0
votes
1answer
162 views

Syntax/indentation problems with Vue mode in Emacs 27 nightly

I'm using vue-mode, based on mmm-mode with Emacs 27 nightly from 10/10/2019. Since that Emacs update, I don't get any indentation support in the script section of a Vue file. Try this file with emacs -...
0
votes
0answers
21 views

How to make the cursor go to the beginning of the line by default when I hit return? [duplicate]

When I hit Enter/Return on my keyboard, the cursor goes to position of character 82 instead of the beginning of the line. This behavior is very confusing to me. Do I need to add something to the ...
2
votes
1answer
109 views

How to remove message `Indentation setup for shell type sh`

I open shell files at startup and often get this in *Messages*: Setting up indent for shell type sh Indentation variables are now local. Indentation setup for shell type sh All my files cause this ...
2
votes
0answers
41 views

Can I use “comment-column” for comments in other modes than emacs-lisp-mode?

Emacs-lisp-mode distinguishes multiple kinds of comments. ; is an "end of line" comment when following code, or a "right-margin" comment obeying comment-column when indented with indent-for-tab-...
0
votes
2answers
88 views

Unusual behavior when overriding `calculate-lisp-indent'

I've modified calculate-lisp-indent as a better solution to the indentation questions here, here and here. By "modified" I mean I overrode the function with advice. After doing this when I restarted ...
0
votes
2answers
63 views

Why is my Python indentation set to 8 locally by default?

I'm running Emacs 25.2.2 on Ubuntu 18.04 for WSL. I launch emacs -q and open a new Python file, test.py. As soon as I hit the Tab key, I notice the indentation is 8 spaces instead of 4. I don't like ...
1
vote
2answers
94 views

How can I represent a 4 spaces indent width as 2 spaces?

For clarity: I mean indents as represented by individual spaces, not tab characters. I'm working with a friend on a javascript project, and while I'm an 80col zealot, he wants to have 4 space indent. ...
0
votes
1answer
34 views

automatic indentation with space like visual studio

Is there any package that covers indentation with space like visual studio? like, if(a==b) ==> if(a<space>==<space>b) for(int i=0;i<N;i++) ==> for(int i<space>=<space&...
1
vote
0answers
44 views

sh-mode: Correctly indent and highlight inside bash's subshell substitution $()?

I noticed that bash will correctly apply syntax highlighting inside the subshell substitution in VALUE="Hello $(echo World)." But when creating a more complicated value, e.g. VALUE="Hello $( ...
1
vote
1answer
186 views

How to change shell-script-mode indentation not to use tabs?

To reproduce my issue, open your .bashrc or a .sh file and type the following: if while echo The if has no indentation. Good. The while has the default four spaces of indentation. Good. ...
1
vote
1answer
97 views

How to stop Emacs from deleting trailing whitespace?

By default, Emacs quietly deletes trailing whitespaces once the user moves on to the next line. To reproduce the issue in plain Emacs, do this: Start plain Emacs: emacs --no-init-file --no-site-file ...
1
vote
3answers
85 views

SMIE Indenting Arguments and Blocks

This is closely related to a previous question I asked here: SMIE Basic Identation and Block Example However, it is sufficiently different (and already big enough) that I might as well ask it as a ...
3
votes
2answers
99 views

SMIE Basic Identation and Block Example

I've tried for a while to create a simple major mode that uses SMIE to perform navigation and indentation, but it seems like even the simple examples that I've found seems to break quite easily. The ...

1
2 3 4 5
9