Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

8
votes
0answers
135 views

Custom indentation for specific lines?

I currently try to figure out, how I can handle some lines specifically without messing up the indentation of the rest of the buffer. Consider the following function MyFunc as an example: void MyFunc(...
7
votes
0answers
358 views

Display tab characters as arrows of varying length

I would like to make tab characters ("\t") display as arrows of varying length, just like in editors such as Notepad++, gedit, Geany, etc. Here is an example with tab width set to 4 and space ...
6
votes
0answers
192 views

How to properly indent application in scheme-mode?

The scheme-mode indents application in this way: (define (x) (x 1 2)) But when the function to apply is the result of another application scheme-mode indents the code this way: (define (f) ...
4
votes
0answers
66 views

indent cl-loop to respect `if else` statements

I have a hard time writing and reading cl-loops with they way they're indented by default as I can't easily tell what the control flow is: (cl-loop for x below 10 if (cl-oddp x) ...
4
votes
0answers
117 views

Like JavaScript prettier but for Elisp

(N00b question.) Is there command/package/snippet to format elisp code (like in my init file) in a standard(-ish) way, like what Prettier does for JavaScript? I'm not only concerned about ...
4
votes
0answers
91 views

AUCTeX indenting after \newcommand

If I use a command that begin a new block (according to AUCTeX), e.g.: \newcommand\Test{\begin{abstract}} And then I start my document: \begin{document} AUCTeX will indent my code as if I typed: \...
4
votes
0answers
358 views

Web mode -indentation is misaligned on skipping semicolons

When i indent javascript code (inside html - web mode) that has no semicolons in it, the next statements are indented right with two extra spaces, <script> function processTemplates(){ ...
4
votes
0answers
380 views

Tuareg mode indentation after the first open clause

I'm working through the Real World OCaml book. Based on the installation instructions, I installed tuareg-mode for editing OCaml code. It is version 2.0.9, which appears to be the latest version. The ...
3
votes
0answers
201 views

How to start a new line

I use Emacs with Evil mode, and I'm starting new line with key o. But I prefer to stay in Evil's normal mode, without going into Evil's insert mode, when starting a new line. When reading the called ...
3
votes
0answers
259 views

highlight-indentation-mode discontinue

I am using spacemacs. When enabling highlight-indentation-mode in python-mode, I found that the vertical lines are not continue, they will be interrupted if there is an empty line. How can I fix this?
3
votes
0answers
461 views

Smart Tab and newline-and-indent

I have the following customizations in my .spacemacs file (defun dotspacemacs/layers () dotspacemacs-additional-packages '(smart-tabs-mode)) (defun dotspacemacs/user-config () (setq-default ...
3
votes
0answers
112 views

preventing indenting to open paren when creating a new block in react-mode

I'm using spacemacs for react development. i like it mostly but I have one issue that is annoying. Currently emacs will try to align certain lines with the last opening paren, so something like this:...
3
votes
0answers
175 views

Highlight indent guides in org-mode src blocks

is it possible to show indentation guides in org-mode source code blocks? I use highlight-indent-guides-mode for highlighting indention and it does not work in org-mode (I think this is because the ...
3
votes
0answers
141 views

Set tab width with no exceptions

I always want the tab width to be 4 spaces, no matter what. How do I do it?
3
votes
0answers
177 views

mix spaces and tabs in python mode

Is it possible with whitespace-mode (or another mode) to only show mix spaces an tabs (in python mode) ? Only highlight if: there is space before tab or tab before space there is space and indent-...
3
votes
0answers
58 views

Indent parenthesized Python expression

I have emacs set up to indent Python code like so: foo( bar, baz ) That works fine. However, that style in a particular program I'm working on very often means I find myself with text like this:...
3
votes
0answers
1k views

Indentation in makefile: alignment in multi-line assignments

What is the best solution for writing Makefile, GNU Makefile specifically? For example: FILES:= file0.cpp \ file1.cpp \ file2.cpp \ fileYetAnother....
3
votes
0answers
470 views

How to make indent-region keep the TAB in Makefile buffer?

A very simple Makefile: all: gcc -o hello hello.c And I already set: (add-hook 'before-save-hook '(lambda () (delete-trailing-whitespace) ;; indent the whole buffer ...
3
votes
0answers
138 views

Turn C Electric Indentation off only for specific characters

Extending Customizing c-mode indentation behavior in emacs-24.4 How can electric indentation be disabled for other specific keys without disabling the entire mode? Specifically, how can electric ...
2
votes
0answers
18 views

Letting evil >> increment org level

In evil mode, >> increments the indentation level of the current line. It does so at an org heading too, even though it would be more appropriate there if it would increase the org level (the ...
2
votes
0answers
40 views

How to control JavaScript indentation?

I am coding in Node.js, each time I want to write something that looks like this: const product = Factory .model('App/Models/Product') .create() I get this as an output: const product = Factory ...
2
votes
0answers
68 views

Strange comment indentation results

I am working with a simple major mode. The format has one single line comment delimiter, i.e., %. However, I get strange results when running fill-paragraph on a comment. Specifically, the result I ...
2
votes
0answers
640 views

Org-Mode correct indentation

I am using spacemacs and try to use full text indentation. When I execute "visual-line-mode" and "adaptive-wrap-prefix-mode" by hand via M-x the text will indent, when I edit it. Of course I tried to ...
2
votes
0answers
102 views

SMIE default syntax : First level of indentation

When you only do that in your major mode : (require 'smie) (smie-setup nil #'ignore) That means SMIE but no grammar, and no rules. And it's great. It makes the point stay on col0 when you TAB and ...
2
votes
0answers
161 views

How to set indentation style substatement-open offset parameter from .dir-locals.el?

Within CC mode, for C and C++ files inside a directory, I'd like to have the open braces following a case/do/for/if/while not indented, whatever the style is and without having to change anything in ....
2
votes
0answers
78 views

How to set web-mode to use single-line comment style instead of multi-line for JavaScript

When commenting C-style code like C++, JavaScript etc., I use single-line comments to be able to uncomment a previously commented region selectively, i.e // This // is // a single-line style // ...
2
votes
0answers
60 views

How to protect LaTeX comment lines from indentation?

When I type <TAB> in a LaTeX file anywhere on a comment line, the comment symbol is moved to the beginning of the previous non-blank line. This also occurs with M-x indent-region. Is there a ...
2
votes
0answers
70 views

Fixed indentation for sectioning commands

I'm looking for a particular LaTeX indentation feature regarding sections, subsections etc. Specifically, I would like to start the text within a section (assuming \section is the highest sectioning ...
2
votes
0answers
121 views

ChangeLog mode indentation breaks when pressing return

For personal notes, I create ChangeLog files of the following format: 2015-01-27+0000 Felix E. Klee <felix.klee@inka.de> * Today, I asked my first question on emacs.stackexchange.com: ...
1
vote
0answers
77 views

c++ mode indentation

If we have a class like the one below emacs is indenting the : (to the initialization list). To be able to match some other editor, is it possible in emacs to indent the : like below? class Test { ...
1
vote
0answers
59 views

C++-mode indenting performance depends on length of previous function?

Using c++-mode in emacs23. UPDATE: In response to some early comments, I tested on emacs24 and emacs25, and see exactly the same behavior. I don't have convenient access to emacs26 or emacs27 (25 ...
1
vote
0answers
113 views

org-cycle behaves differently for src blocks when evil-mode is enabled

I'm trying to indent my code in org src blocks, but it only works when evil-mode is disabled. I have set this variables for org-mode: (setq org-src-preserve-indentation t org-src-tab-acts-...
1
vote
0answers
38 views

Hide region from syntax highlighting and indentation

c++-mode does not handle the C++17 R"delim()delim" string literals. Is there a way to mark a region (via comments?) so it will not be syntax highlighted and will not confuse the indenter?
1
vote
0answers
85 views

indent items in auctex

What I would like to achieve is a deeper indentation of lines in items in Auctex. \begin{itemize} \item This is what I would like to achieve. The beginning of the second line aligns with ...
1
vote
0answers
144 views

Should K&R indentation work in C++ code?

Given the following file, named as x.cpp I get the following unexpected indentation behavior: #include <stdio.h> class X { public: X() { // <-- Why the indent? ...
1
vote
0answers
737 views

spacemacs, web-mode, cannot indent

I am using spacemacs. When writing .html file, it shows that it is in web-mode. I want to indent, press TAB, but nothing happened. So I can only use SPC to indent. I added (setq web-mode-markup-...
1
vote
0answers
29 views

How to indent when type } ) or ;

I found a way to auto indent when I type one of }, ; or ) using this code: (setq mode-autoindent-list '(javascript-mode js-mode php-mode web-mode)) (defun mode-autoindent () (when (and (member ...
1
vote
0answers
108 views

Prevent emacs to indent when yanking into html buffer

I have disabled electric indent mode, as specified here, but when yanking text, indenting is still performed. I am yanking text into an html buffer, and I do not want any change whatsoever to be ...
1
vote
0answers
61 views

Make backspace(+?) remove a level of indentation in ReST mode

I often find myself in the situation where ReST-mode has correctly identified that my last line can be followed by an idented line, but I want to continue on the next higher level of indentation. How ...
1
vote
0answers
508 views

setting csharp mode indentation to 2 spaces

Complete emacs/lisp newbie trying to switch from vim. I noticed that emacs indents C# files to 4 spaces, which is normally great, but I'm working on a project that requires 2 space indentation. I've ...
1
vote
0answers
159 views

How to indent a tex file like org-mode?

When I'm editing a org-mode file, the structure of mine is like this(you may need configuration in init.el): * A section This is the content of the section #+BEGIN_SRC lang code here #+...
1
vote
0answers
298 views

Modifying auto-indent in emacs with python

I often write python code in which a function returns a value. Often I will define that value higher up in the code as "returnvalue" or some similar name. Then the next line is indented ...
1
vote
0answers
126 views

Web-mode javascript indentation for “if” and “for”

When writing Javascript, I always put curly brackets after if in a new line, like this: if(a == 0) { .... But when I do that in web-mode, the default is like this: if(a == 0) { .... ...
1
vote
0answers
76 views

emacs: specify 2 or 4 space indentation for C-j electric-newline-and-maybe-indent

I'm using emacs 24. I work on a variety of html files, sometimes there's blocks of html with two space indentation, others have four space indentation. When I press C-j , emacs assumes i want 4 ...
1
vote
0answers
96 views

Auto-indent problems related to syntax in Haxe-Mode

In the Haxe programming language, you can specify the type of the return value of a function with a colon. function funcName() : ReturnType { } This becomes a problem when using emacs with haxe-mode....
1
vote
0answers
67 views

Is there an electric-indent for single-line statements in braced languages?

My code style for braced languages like C/C++/Java is to use no braces when the statement is a single line. One of my biggest pet peeves is that every IDE I've ever used will not smartly un-indent ...
1
vote
0answers
316 views

How do I make lua indent two indentation units for a line continuation

For my current works style guide I need to indent two units (tabs in their case) for a line continuation. the default in emacs lua mode appears to be one. e.g. (assuming two spaces are a tab or an ...
1
vote
0answers
86 views

Swift major mode indentation is not moving to expected position

When I type a } to close the for loop, the '}' is moved to position as shown in the screen shot (where the cursor is) I expect it to be at the same column of the for keyword. Indentation for lines ...
1
vote
0answers
94 views

getting the “right” indentation via my c++-mode-hook

Using GNU Emacs 24.5.1 My c++-mode hook has (c-set-style "cc-mode"). This works fairly well for me, with the following exceptions: First of all: try-blocks are indented int main() try { ...
1
vote
0answers
430 views

c-indent-line-or-region: Variable binding depth exceeds max-specpdl-size

I'm trying to define a new major mode using define-generic-mode and want to try reusing c-indent-line-or-region for my indent-line-function. I've inserted (set (make-local-variable 'indent-line-...