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
17 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
13 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
0answers
10 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
10 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
13 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
0answers
29 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 ...
1
vote
1answer
26 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
17 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
75 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
32 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
81 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
30 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
23 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
61 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
60 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
54 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
79 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
31 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
28 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
26 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
70 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
36 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
117 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
33 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
60 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
35 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
24 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
51 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, ...
2
votes
1answer
32 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
61 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
29 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
60 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
30 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
73 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
56 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
110 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 ...
1
vote
1answer
61 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
52 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
29 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
27 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
36 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
91 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
66 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
31 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
76 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
136 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
64 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 ...