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
0answers
3 views

How to fix indent of multiline dotpaths in javascript

I would like my code to look like this: this.imgs.push( $('<img>').attr('src', data.src) .css('position', 'absolute') ); this.imgs[i].css('left', data.x) ....
0
votes
0answers
51 views

Make tabs behavior like in other IDEs

How can I force Emacs to use tab button and TAB character in "normal stupid way"[1], like in nano or VScode or JetBrain's IDEs. All I can find is smart-tabs package and indent-tabs-mode, but ...
0
votes
1answer
29 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)) ...
2
votes
1answer
91 views

Emacs auto-indenting comments in an unhelpful manner

New Emacs user here. Hitting enter after a semicolon commented line in any file type (.el and .lisp at the very least) indents the comment in a very unhelpful way that I have to assume is not intended ...
0
votes
0answers
10 views

How to disable `clean-aindent-mode` in spacemacs configuration

I noticed that clean-aindent-mode is messing up the indentation as I am writing python files. Hence, I wanted to disable this mode, at least when using python mode. I can manually disable this mode, ...
1
vote
2answers
70 views

How to turn off automatic indenting for Org files in a specific folder?

I am using Doom Emacs. I like having indentation for most of my org files, but I have one folder where I want to have org files without indenting, to use for writing documents. I have already tested ...
1
vote
1answer
67 views

How do I make emacs indent relative to the beginning of the previous line?

Here's how emacs indents e.g. Python code: a = myfun(b, c) I'd like it to be this way: a = myfun(b, c) Reasoning? If I later replace myfun with myfunction, in the first case it becomes:...
0
votes
0answers
13 views

Aligning the colon in multi-line tertiary expressions in C and C++

Suppose I have the following line double dx = r1 < 1 ? sqrt(r1) - 1 : 1 - sqrt(2 - r1); I press enter and tab at the colon causing Emacs to align like this: double dx = r1 < 1 ? sqrt(r1) - 1 ...
0
votes
0answers
39 views

Unable to change emacs python indent

My Emacs's python-indent-offset is fixed at 2, even though I have the below code in my init.el to set it to 4. I used C-h v to describe the variable, it says its value is 2 and default is 4. I removed ...
1
vote
1answer
24 views

Spacemacs gg=G replacing tabs with spaces in org-babel makefile block

I'm using Spacemacs, and my org-mode file contains an org-babel block of Makefile code, which I want to "tangle" so it becomes part of the source code while remaining in sync with the ...
0
votes
1answer
17 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}}...
0
votes
0answers
21 views

web-mode - PHP code indentation

I have been using Emacs for some time but I am quite new for PHP and Web development. I want to use Emacs as a PHP editor. I have searched a lot of pages and I have found that many people recommend ...
0
votes
0answers
13 views

Correctly indent whole buffer in auctex wihtout filling

When using AUCTeX to edit LaTeX files you can call LaTeX-fill-buffer to fill the whole buffer and additionally indent everything correctly. However if I am using visual-line-mode (together with ...
0
votes
0answers
6 views

nxml: Indent tag attributes on new lines 4 characters, not below attribute on parent line

I put attributes for XML tags onto a new line when the tag line gets too long: <flux:field.inline.fal name="settings.image" required="1" maxItems="1" minItems="0" collapseAll="1" ...
0
votes
0answers
11 views

Custom indentation blocks in c++-mode?

Is it possible/easy to add custom markers for the start/end of indentation blocks in c++-mode? I'd like the indentation of a block of code like BOOST_AUTO_TEST_SUITE(SuiteName) // <<TestCases&...
1
vote
1answer
32 views

Python over-indentation warning E127

elpy (or rather flake8 I suppose) complains about a line over-indented on the line 52 (see below image) I tried to change this line's begin but no change. I always use TAB to have the correct ...
0
votes
0answers
17 views

Making input easy to read (Macaulay2)

I am using Emacs to run Macaulay2 (I'm a newbie at both). I have a long input written in an m2 file, which I then press f11 to input to Macaulay2. I would like to make my input more aesthetically ...
0
votes
0answers
15 views

SMIE: bare opener forces “hanging” indent

If I use the default SML mode parser, or other SMIE parsers, and have a rule for if-then-else as an expression form, I get reasonable indentation of x + if p then q else ...
0
votes
1answer
21 views

SMIE precedence conflict

(defvar foo-smie-grammar (smie-prec2->grammar (smie-bnf->prec2 '((exp (exp "+" exp) (exp "*" exp) ("let" let-decls "in" exp)) (let-decls (let-decls ";" let-...
0
votes
0answers
26 views

How to fix indentation of anonymous structures in function argument position in C?

I've been stumbling upon this constantly. Suppose that I have a function that accepts a structure, or a pointer to a structure: struct s { int n; char c; }; void f(struct s *s); I'd like to ...
1
vote
0answers
12 views

auto intendation on newline doesn't stay at same indentation for python docstring

Ubuntu 19.10 emacs 26.3 from system repos I do use elpy and evil-mode In general when I am editing python code, indentation works just fine. However, when I am editing doc-strings, when I type enter ...
1
vote
1answer
27 views

setq in init file not overriding the default for indent-tabs-mode

It works when using setq-default in place of setq or when customizing through C-h v. C-h v reports that it is set in 'C source code'. I was thinking it might be affected by my c-default-style, but my ...
0
votes
0answers
22 views

Editing mode for OpenBSD .conf files

Can GNU Emacs edit OpenBSD configuration files (/etc/*.conf, curly-brace syntax) with auto-indentation and syntax highlighting? conf-mode does not seem to handle that syntax in Emacs 26. c-mode ...
1
vote
2answers
65 views

Always show the last lines with a lower indentation than the first line that's visible in a window

I often find myself scrolling up in a code file to see which context I am in (class/method definition, yaml-key, etc). It would be super handy if I could somehow "freeze" the last lines of each ...
0
votes
0answers
12 views

smie handling of expression prefixes inside its s-expressions

In the SMIE implementation of SML, ! is given the "expression prefix" syntax class. This seems to lead to a strange tokenization, such that its notion of s-expression (e.g.,if-then-else blocks) gets ...
0
votes
3answers
43 views

How to disable autoindent on new line?

I find a lot of questions similar to this, but not one with an answer that matches what I need. I'm using spacemacs in evil mode, and I want "new lines" (done with RET in insert mode, or o or O etc) ...
0
votes
1answer
18 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
1answer
68 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'...
1
vote
0answers
16 views

web-mode turn off auto indent on yank [duplicate]

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
30 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
72 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
36 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?
2
votes
0answers
23 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
41 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
30 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
199 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
131 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
35 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), ...
5
votes
1answer
88 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
13 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 ...
2
votes
0answers
36 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
32 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
49 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
53 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
42 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
38 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
84 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 ...

1
2 3 4 5
9