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
21 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
18 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
34 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
52 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
44 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
45 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 ...
0
votes
1answer
19 views

Does it exists any library and or functionality that provides an API for indenting major modes?

I am currently maintaining a fork of a major mode and I usually get by through reusing snippets other people have written that provides indention for similar languages. However, this does lead to a ...
0
votes
1answer
25 views

How to align “end of line comments” in sh-mode?

I moved to column 60 of the first line and evaluated set-comment-column. Then I moved to the second column and called indent-for-comment, but it indents the comment randomly but not at column 60. How ...
0
votes
0answers
26 views

Refresh code indentation over a region

I have this: #!/usr/bin/bash while read f; do { #Try echo "$f" } || { # Catch printf "error" } done < "${1:-/dev/stdin}"; And I would like this in one ...
0
votes
0answers
26 views

Annoying indentation bug with ES6 multiline string using js-mode or js2-mode

I am using js2-mode right now. I am working on a .js file that contain a ES6 multi like string like this: Vue.component("comment", { props: { comment: { type: Object, ...
0
votes
1answer
24 views

Shift all tags in file to the right

In a .org file, I can align all my tags to the right with C-u C-c C-q. I'd like more space before text runs into tags in a file. Is there a variable for the location of the tags column in the org ...
2
votes
1answer
65 views

How to indent inline elements only once?

In this case the basic offset is 4 and tabs mode is enabled. For example I am getting: if (! (true // Problem when the value starts inline. && false)) {} // I get two tabs, one per '(...
1
vote
1answer
35 views

Adding rule to indentation

A code base I work on has the macro #define when break; case to make switch statements 'cleaner' However this causes problems with indentation, Is it possible to set the behavior of 'when' to be ...
1
vote
2answers
78 views

How can I get flush left text in org-indent-mode?

I open an org file in emacs and it displays thus: I enable word wrap with M-x visual-line-mode and get: But I prefer the extra indenting of headlines provided by org indent mode, so then do M-x org-...
1
vote
1answer
30 views

Align statement breaks on rhs with equal sign

Is there a way to have rhs statement breaks align with the equal sign on the lhs line? e.g. some_value = a * b + c / some_other_value * x; becoming some_value = a * b + c / ...
4
votes
1answer
50 views

Custom indentation for macros in C mode

I'm working in a codebase with an extensive use of function macros and I'm having some difficulty finding the correct way to set indentations with them. Specifically, we pass a lot of statement lists {...
0
votes
1answer
30 views

Breaking up minified html

Is it possible to do this with vanilla emacs? If not what changes do I need to make. Original test.html <a id="try_redacted" target="_blank" href="http://redacted.com/game/2d/?try=1" style="right:...
0
votes
0answers
23 views

Convert gnu indent options to emacs indentation settings

I've worked at two places where code is supposed to be indented/formatted according to gnu indent (ie there's a prescribed set of options to gnu indent that's to be used). Is there an easy way to set ...
0
votes
1answer
44 views

Python Documentation String Indent In Auto-Fill Mode (Emacs 26.2)

I've noticed a peculiar behavior when using auto-fill-mode editing Python code. For example if I start typing the following (fill-column is set to 79): def some_function(keyword_argument0, ...
1
vote
1answer
25 views

How to stop web-mode from reindenting after yank?

I'm editing this code: callFunction({ x: somearray, }); Then I want to extract somearray to be a variable with a copy. I cut somearray and delete the colon, then enter (_ is the cursor): const ...
0
votes
1answer
42 views

How to indent truncated lines?

For me it seems like a really ruff edge that default spacemacs comes without an option to give my lines a correct indentation, when they are wrapped. (Click the first link if you want to see the issue ...
0
votes
0answers
24 views

How do I disable full-buffer indentation after each yank in web-mode?

In editing html/php mix in web-mode, I inserted a single line by a yank 'C-y' and the full buffer (it says region) is re-indented. It takes a large amount of time. It even throws a warning: "Warning (...
3
votes
1answer
43 views

SML Mode weird indentation

Whenever I hit enter to get to the next line when writing a function for example emacs indents an addition tabs worth of space. I'll try to sketch out the problem: fun pow(x : int, y : int) = ----...
2
votes
0answers
25 views

Indentation with reader macros: common lisp in emacs

Okay, I'm not sure whether this question is more relevant to Common Lisp, or to Emacs. I have reader macros in Common Lisp (found them here), that allow the declaration of hash-tables by: #{'a 'b, '...
0
votes
0answers
55 views

Evil-mode mixed tabs & spaces indentation

I'm having extreme issues at the moment with evil mode where I am working on Jade/Pug and Stylus files for Node.JS where it is white space sensitive. I installed pug-mode but when you indent via >> ...
5
votes
1answer
43 views

Indentation of description lists

org-mode automatically indents description lists, but it uses two different schemes. For short labels, the second line of the description is aligned with the first character of the description. For ...
2
votes
1answer
80 views

Manual indentation in LaTeX mode

I'm new to Emacs, and dislike the default indentation in LaTeX mode. I want the indentation to do the following: insert a \t character (not spaces) be completely manual (I want to have to press Tab ...
0
votes
1answer
50 views

Previous indentation is discarded on newline

Let's say I have the following code: void foo(){ ~ } I have marked point with ~. When I press enter the electric indentation works as normal but it doesn't keep the indentation for the previous ...
1
vote
0answers
49 views

How to fix indentation of C++ methods with ref-qualifiers?

Emacs in its default configuration seems to have trouble indenting C++ methods with reference qualifiers (& and &&). For example: struct foo { void a_method() && { ...
1
vote
1answer
28 views

Keep text selection after indenting with evil

I'm using emacs with evil key-bindings and I like to know, after getting some text into visual mode, how do you make sure that after hitting >> for indenting the text, the selection is kept, ...
0
votes
0answers
19 views

Can I force erlang-mode to use 4-spaces for indents?

I'm working within a small team writing Erlang. I'm the only developer using Emacs. The Erlang code the rest of the team outputs is indented using multiples of 4 spaces. For example: ...
0
votes
1answer
35 views

Indentation broken with all \input{files.tex}

Everything is in the title : a master.tex file contains several \input{subfileXX.tex} ; the indentation works in the master file but not in the subfiles. The TAB key acts like in LibreOffice.
0
votes
1answer
82 views

Indentation: 4 spaces everywhere

This morning, my Emacs changed its indentation rules, and now it indents by 2 spaces, specifically in JS and HTML. It even re-indents code on which I work to 2 spaces, which is unacceptable. Please ...
1
vote
2answers
59 views

Getting electric indent behaviour for added chars to “electric-indent-chars”

I am trying to get electric indent behaviour in bazel BUILD files. These are essentially python files, although the structure is extremely simple. Let me give you an example: cc_binary( name = "...
3
votes
0answers
30 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
1answer
60 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 ...
0
votes
1answer
97 views

CC mode: make Tab just insert one tab or complete, no auto-indenting

I am dissatisfied with current behaviour of Emacs in CC Mode. I'm not sure if this applies to other major modes, but that's one I'm currently struggling with. Here are my problems: When I press tab, ...
1
vote
1answer
50 views

Which variable modifies the switch statement indentation on php-mode?

I am currently using php-mode with spacemacs to write in php and recently I noticed this auto-indent behavior, namely pressing TAB. switch ($cond) { case "something": break; } Auto indenting ...
1
vote
1answer
321 views

Can’t guess python-indent-offset - delete warning when local file variable

I have this comment that I write in my python file # -*- Mode: Python; tab-width: 8; indent-tabs-mode: nil; python-indent-offset: 2 -*- # vim:set et sts=4 ts=4 tw=80: But when I load a python file, ...
0
votes
0answers
24 views

unexpected long indent after colon in web-mode

I have some trouble locating the source of 8 tabs and 3 spaces more than the previous indentation when I'm inside js inside web-mode. These appear after a line that ends with a colon. Example (note ...
1
vote
1answer
47 views

Indent forwards a tree structure

I have such a structure in my org note **** pstree * ~ $ pstree -aps 26955 systemd,1 splash └─systemd,1947 --user └─gnome-terminal-,2710 └─bash,1775 └─emacs,25135 ...
0
votes
1answer
35 views

How do I suppress indentation after labels in Groovy?

I'm writing some Groovy code, and in my unit tests I have something like the following: def testFoo(){ given: //setup statement 1 //setup statement 2 //... when: //Execute ...
2
votes
1answer
65 views

Emacs indents C++ functions in structs in an unexpected way

Emacs indents functions in structs in the following way: struct A { int a() { return 1; } int b() { return 2; } } int c() { return ...
0
votes
1answer
280 views

highlight-indent-guides-mode

I'm trying to activate highlight-indent-guides-mode by default but it is not working. If i do M-x highlight-indent-guides-mode it works fine but adding (highlight-indent-guides-mode 1) to my .emacs ...
0
votes
1answer
101 views

How to set tabulator size in the awk mode?

After installing a new kubuntu (16.04) and emacs (25.2.2) I have had indentation problems. It seems like indentation default values have changed or maybe I am missing some configuration file? ...
1
vote
2answers
118 views

Babel + Python function definition with for loop causes IndentationError

I am using orgmode and Babel to run Python source code blocks. I noticed that if I define a function that returns a value, and if this function has a for loop inside it, then evaluating it with Babel ...
0
votes
2answers
26 views

Automatic re-indentation

I'm using Emacs to write ocaml programs, and the automatic indentation works fine : suppose I write if in the middle of a line, then skip a line and write then ; the keyword then is automatically ...
0
votes
1answer
97 views

Customizing indentation style for continuation lines?

I would like to customize the "k&r" indentation style, so that continuation lines are indented 8 spaces, like this: if (first && second) { // <- 8 spaces. third(); } -- ...
0
votes
2answers
236 views

Confusion about space and tab characters in Emacs

I am confused by space (SPC) and TAB characters in Emacs. I am often using the default fundamental mode. When I select a region and indent the lines in the region by C-u 9 C-x TAB, I intend to ...
0
votes
0answers
38 views

Prevent spacemacs from splitting lines of C++ code

I installed the c-c++ layers in Spacemacs. When I invoke indent-region, Spacemacs splits lines that are longer than 80 characters. How can I prevent this behavior? auto-fill-mode is not enabled and ...