Stack Exchange Network

Stack Exchange network consists of 174 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.

0
votes
1answer
75 views

Customized c-offsets-alist override c-file-style in dir-locals

Assuming I customized my default C indentation settings through M-x customize-variable c-offsets-alist: (custom-set-variables '(c-offsets-alist (quote ((statement-case-open . 0) (...
0
votes
2answers
240 views

prevent auto indent temporarily for multi line conditional, loops, etc

When I am writing in c-mode, I prefer to write multi-line control statements in the following way. if( cond1 && cond2 || cond3 ) { /* stuff */ } for( i = 0; i < N; ++i ) { ...
0
votes
1answer
30 views

Which value for topmost-intro-cont, to align variable names in c-mode?

In c-mode, how to align following code so, that the second variable name's starting character (A) is aligned below the first variable name's starting character (V)? static unsigned int V_name_1, ...
0
votes
0answers
42 views

How to indent c++ “special” source lines that don't end with semicolons

I'm working with a system that uses special macros a lot. For instance: class UDSSLib : public UFunctionLibrary { GENERATED_BODY() void foo(); int i; } The problem is the GENERATED_BODY() line....
1
vote
3answers
114 views

Indenting `cl-flet` etc

Is there a way to indent cl-flet, cl-labels etc. using the CL style without resorting to (setq lisp-indent-function #'common-lisp-indent-function)? cl-indent.el claims that: common-lisp-indent-...
0
votes
0answers
17 views

Align closing bracket of multiline array left when used as method argument

When I pass a multiline array as an argument, I'd prefer that the elements were aligned like this safe_join([ "abc", "def", ]) But ruby-mode indents it like this: safe_join([ "abc", ...
0
votes
0answers
30 views

Change Java indentation spacing of && ampersand

I'm having some trouble finding the customization of Java style in Emacs for newline && ampersands. I'm using just electric indent mode. Current style: return c.booleanSomething() &&...
0
votes
2answers
149 views

Is there a way to disable automatic indentation when editing an existing line?

There are cases where my indentation style does not follow what Emacs thinks it should be. (I believe that coding standards should be guidelines, not strict rules, and that deviations should be ...
0
votes
1answer
314 views

python-mode: tab always indents with 2 spaces

I start up my Emacs25 with emacs25 -Q to skip any init.el. When I then open a python file with local file variables as shown below, TAB indents only two spaces, instead of four: # -*- mode: Python; ...
0
votes
1answer
60 views

Why can't I bind tab to multiple spaces? [duplicate]

I'm trying to bind tab to either a tab or multiple spaces in Latex/ESS-noweb mode but I can't get it to work. I tried (local-set-key (kbd "<tab>") 'self-insert-command) which didn't work, and ...
1
vote
0answers
36 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?
0
votes
1answer
67 views

opening brace alignment/indentation problem in LaTeX mode

I have an alignment/indentation problem in LaTeX mode. Every time I begin a line with an opening brace and I hit <TAB> or run an indentation command on the region, the brace becomes aligned with ...
1
vote
2answers
152 views

Function for creating a new line but leaving point in same column

Is there such a function? It should correspond to pressing return and space enough times to get back to the old column. I believe this is known as a linefeed?
1
vote
0answers
81 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 ...
0
votes
0answers
45 views

How to indent the code between the backslash or single quotation mark in Emacs sh-mode

Writing shell scripts using Emacs need indent the code between single quotes or backquotes in many cases, for example: string=`SSH remote host | foo | bar` # backquotes or command | awk '{...}' # ...
1
vote
1answer
150 views

White space being inserted before a semicolon in asm-mode

When I try to insert a semicolon in my code (in asm-mode) it seems to indent a certain number of tabs like this (usually 4 it seems): D ; And if I put another semicolon on the next ...
2
votes
2answers
98 views

indentation (with multiline comments) in batch processing

i'm trying to indent a couple of C++-files (and untabify them; and remove trailing whitespace), so i thought about using emacs in batch mode. Since I'm pretty much a noob when it comes to elpa (or ...
1
vote
1answer
37 views

c-basic-offset is not influencing indentation of c/cpp files

No matter how I set this value I get this message when I try to describe it. Its value is 2 Original value was set-from-style Local in buffer .... ; *Global value is 3* I don't know what is ...
1
vote
1answer
137 views

Aggressive SQL indentation in emacs

I want an emacs SQL indentation function with the following properties: Upcase { select, from, as, where, group by, order by, asc, desc, and, or }. - EDIT: there are sqlup-mode.el and sql-upcase.el ...
3
votes
0answers
187 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 ...
0
votes
2answers
67 views

Function that deletes redundant leading whitespaces of a region while maintaining indentation

Is there a Elisp function that deletes "redundant" leading whitespace of the region while maintaining relative indentation. This behavior is like textwrap.dedent in python. https://docs.python.org/2/...
1
vote
1answer
68 views

Value of symbol c-basic-offset in a function

I am using a mode that has the following construct: (defun robot-indent() "Returns the string used in indation. Set indent-tabs-mode to non-nil to use tabs in indentation. If indent-tabs-mode is ...
1
vote
2answers
160 views

What prevents emacs from indenting and how can I force it to?

In certain modes, such as Python I have noticed that Emacs will not indent how I want it it to. It is getting "smart". For instance, in this block of code: def vec_select(veclist, k): ...
0
votes
1answer
56 views

Autoindent yas-snippets which call up another function

I use the snippet function_docstring_numpy (shortcut: fdn) in python to define nicely documented functions. They look like this: def flip(batch): """Flip a batch of images Works for a single ...
1
vote
0answers
15 views

Personalize indentation for new C++ language features [duplicate]

I'm starting to use C++-17, and one of the new features is if constexpr, which breaks completely the usual if identation: int main() { if constexpr(true) { return 1; } else { ...
3
votes
1answer
73 views

Electric indent not indenting closing brace in perl-mode

Starting with emacs -Q, I open a C file a.c and a Perl file a.pl. I turn on electric-pair-mode and electric-indent-mode in each. In a.c, I enter the following, where the | shows the cursor position: ...
1
vote
1answer
219 views

Indenting within block comments in C-mode Emacs

After writing functions in C/C++, I like to format my block comments that explain a function's purpose, parameters, use, and so on. (See example below) However, to indent my comments in emacs, I ...
8
votes
1answer
281 views

formatting constexpr if in c++-mode

I recently started using C++17, which brings constexpr if. This however screws up c++-modes default indentation. // emacs 25.3.2 with --no-init if constexpr (n == 1) { // Why? } else if ...
3
votes
1answer
74 views

How to tell Emacs to keep indentation in algorithmic environment?

I frequently find myself typesetting algorithms, and I choose the algorithmicx/algpseudocode package for that. I like the package, it is simple to use and has everything I typically need. The problem ...
0
votes
0answers
43 views

How do I define a simple indentation rule for a custom mode?

I'm making a custom mode for an internal DSL that we use at work. I have nailed the highlighting and just need to get around making indentation work. The language itself is just S-expressions so I ...
4
votes
0answers
105 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 ...
1
vote
1answer
227 views

Making AUCTeX use tabs for leading indentation doesn't work

This answer says how to make AUCTeX use tabs for leading indentation. However, it doesn't work for me and I don't understand why it doesn't. After adding the code to my init file, LaTeX-mode just ...
0
votes
0answers
212 views

Indentation after cout in C++ mode

I have a problem with indentation after: cout << "...." ....; lines in c++-mode. Expected cursor position after pressing Enter is the next line and column is right under cout. But as you may ...
0
votes
1answer
318 views

how to get correct indentation after pressing 'o' in haskell-mode using evil-mode in spacemacs

When using haskell-mode (the Haskell layer) with evil-mode keybindings in spacemacs, the indentation created by pressing the o key is often incorrect. For instance, imagine I want to write the ...
5
votes
2answers
159 views

copy region without leading indentation

I often find myself copying a region of code that is deep inside the indented structure. Since I don't want it to end up in a codeblock with superfluous indentation (given that the context is missing),...
0
votes
1answer
77 views

rst mode indentation problems (electric indent off)

I've turned off electric indent. I am still having serious indentation problems with rst-mode -- making things nearly unusable. First: I'd like to make all indentation two-spaces. No tabs, not ever. ...
2
votes
1answer
171 views

How to use custom macro indentation in elisp?

This blog post shows that its possible to indent like this: (lispy-dotimes arg (when (= (point) (point-max)) (error "Reached end of buffer")) (forward-list)) Instead of this: (lispy-dotimes ...
0
votes
1answer
1k views

how to align python code in a long block?

In python, indentation level defines (?) a new block. for a in range(10): print(a) for c in range(10): print(c) ....... # I'd like to code here but hard to know if lines are long.. ...
0
votes
1answer
273 views

How to fix incorrect emacs C#-mode indentation for method braces

My problem is that Emacs incorrectly indents the braces for C# methods, like this: static string LOL() { } then I have to manually correct it to static string LOL() { } I have read ...
2
votes
0answers
563 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
96 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 ...
7
votes
3answers
470 views

How to make emacs align and indent a bibtex entry?

I want bibtex-mode to align and properly indent fields. I copied a bibtex entry for the following article into Emacs: (Article source here) But, with a simple paste, the alignment is lost in Emacs ...
1
vote
1answer
132 views

Why do multi-line comment blocks influence C++ indentation?

I'm a long-term Emacs user who recently started to learn C++. I was surprised to discover that indentation for C++ is actually rather bad, specifically in files containing multi-line comment blocks. ...
1
vote
2answers
400 views

css-mode: use tabs and not spaces

How do I make it so tabs are used instead of spaces when TAB is pressed? I've tried setting indent-tabs-mode to t but no dice. On my other modes, such as php-mode and c-mode, tabs are inserted. CSS ...
1
vote
1answer
804 views

How can you make conf-mode indent with tabs?

When I open a config file that has been indented with tabs, the mode shows as (Conf[Space] WS) and pressing Tab indents with spaces, even though the rest of the file is using tabs. How can I change ...
2
votes
1answer
170 views

How to detect and match indentation size of current buffer

I'm working on a javascript project that has inconsistent tab sizes 2spaces vs 4spaces on the server and client. I'm using web-mode for javascript editing. I'm looking for a feature like SublimeTexts ...
2
votes
0answers
150 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 ....
7
votes
0answers
330 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 ...
1
vote
1answer
1k views

How to detect tabs or spaces in Emacs

By default I want all indentation (when I hit the tab key) to be 2 spaces. However, when I am editing certain Python files (where I can not mix tabs and spaces) I would like to use whatever the ...
0
votes
1answer
207 views

Backwards tab-to-tab-stop?

The tab-to-tab-stop command moves the point to the next tabstop; I can't find an equivalent to move to the previous tabstop and tab-to-tab-stop doesn't accept a universal argument to reverse direction....