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.

6
votes
2answers
136 views

Python cycling through indentation

Cycling through indentation levels in python.el 1 can be achieved by pressing <tab> repeatedly, which is bound to indent-for-tab-command. Now, consider: (defun malb/my-indent (&optional ...
4
votes
1answer
196 views

Weird indentation behavior in C++ mode

In C++ mode there is the following behavior of the indentation: Why is this happening? How can I fix it?
2
votes
1answer
565 views

Python docstrings only allow two indent levels

I am trying to write a docstring that follows Google's style guide such that it looks something like: def testFunction(a, b): """ Args: a (str): b (str): Returns: ...
13
votes
3answers
269 views

Navigate by indentation

I want to navigate between the lines of a file based on indentation. The file is structured by indentation: a line that's more indented than the previous line is a child of the previous line, a line ...
5
votes
2answers
619 views

Change the behaviour of RET (with electric indent) to only indent the new line, not the previous one

https://stackoverflow.com/questions/27077770/how-do-i-disable-electric-indent-on-ret-but-still-keep-other-electric-characters asks and answers how to disable electric indent when pressing RET. All ...
0
votes
0answers
261 views

web-mode javascript auto-indenting without semicolons

I'm editing JSX files with web-mode and our project doesn't use semicolons at the end of the line. Whenever I press enter at the end of the line, web-mode is auto-indenting two spaces because the ...
4
votes
0answers
85 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: \...
1
vote
1answer
142 views

How do I enable indentation in an inferior scheme?

There doesn't seem to be any indentation in the default inferior scheme. At least, when I do M-x run-scheme the resulting repl doesn't indent my code at all. How can I change this? Preferably without ...
3
votes
0answers
134 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?
1
vote
1answer
1k views

Indenting lists in org-mode

I copied and paste text in an org file and formatted it as a list: - Funded pensions :: As explained more fully in Chapter 3, funded pensions are paid on behalf of its members. How can I have the ...
0
votes
1answer
194 views

Setup c-mode indentation, braces and tabs

I've been trying to setup cc-mode based files to behave in the way I want, but with so many varying opinions and suggested ways of doing things, I've not been able to get things just right. All I ...
1
vote
0answers
75 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 ...
19
votes
2answers
544 views

Is there any SMIE documentation that is clear?

I've spent many, many hours now trying to get any sort of SMIE indentation rule/grammar/thing working. Are there any examples of a small, toy or skeleton SMIE-based mode with documentation on how it ...
1
vote
1answer
285 views

Emacs indent AngularJS code to wrong level

It's really sad not to write well formatted angularJs code inside emacs, the image below shows what I am saying. What is happening inside the photo is that the code is already well formatted as it is,...
0
votes
1answer
201 views

Find out C indentation rule at point

If I recall correctly I was able to view the C indentation rules applied for indenting the line at point. After searching the manual for a while I still can not find the command for it. Obviously I'...
0
votes
1answer
360 views

How to make the tab key act normally in C++ mode?

I'm switching over to Emacs as my C++ editor, and what I miss the most is when I use tab, it would write 8 spaces, I could use tab more than once and use it in the middle of code, when I pressed back ...
7
votes
2answers
2k views

no html/jsx indentation in jsx-mode

For some reason the html/jsx in my react source files always wants to indent as follows, i.e. there is almost no indentation: return ( <DateRangePicker ranges={this.state.ranges} startDate={this....
0
votes
1answer
192 views

How to Self Insert Tab When Editing String In go-mode?

The title contains the crux of my question. In go-mode, tabs and auto-indentation generally works well, except when I am editing strings. When inside of a string, I'd like the tab key to self-insert. ...
2
votes
2answers
987 views

How to change the indentation of major mode (SQL-mode)?

Configuration: Emacs 25.0.50 on Ubuntu 15.04. How to produce? Do emacs -Q, then M-x sql-mode. Paste the following in the buffer: SELECT SUM(T01.foobar) FROM db_foo.bar T01 WHERE T01.fooID = ...
1
vote
2answers
65 views

CC-Mode doesn't indent arguments to templated functions starting with a curly bracket

[Reposted here after a comment from wilx on stackoverflow.com] Consider the following snippet of C++ code, indented using cc-mode: auto good1 = f(a, {1, 2}); // ((arglist-cont-...
2
votes
1answer
108 views

Stop 2nd TAB from undoing indenting

I noticed something that might be a feature, but I find it rather annoying. Say I have a piece of code: some_function = (x, y) -> z() and I wish to add a new function call one indentation level ...
4
votes
1answer
237 views

Python-mode: maintain indentation before closing brace?

Python's style guide (PEP 8: Indentation) suggests two alternatives for indenting the close paren for a multi-line function call. some_function( first_long_argument, second_long_argument, ...
6
votes
1answer
498 views

How to indent without the two extra spaces at the beginning of code blocks in org mode?

By default org mode source blocks looks like: #+BEGIN_SRC emacs-lisp (dcg/add-to-list 'package-archives '("melpa-stable" . "http://stable.melpa.org/packages/") ...
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
3answers
392 views

How to add four spaces selected region [duplicate]

I'm using Firefox extention It's all text, with it I can edit stackoverflow form text in Emacs. Therefore I often want to add four spaces before selected text to markdown codes. indent-region only "...
8
votes
0answers
133 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(...
3
votes
0answers
171 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-...
0
votes
2answers
897 views

C++ indentation after member initialization list

When I add a member initialization list to my class constructor, Emacs indents the body like this: Vector::Vector(int s) : elem{new double[s]}, sz{s} { } I expect it to be indented the same ...
0
votes
2answers
46 views

New line should start at first column

When I enter a new line the cursor always jumps to the column which was the starting column the line before! I would like for the curser to stay in the first column until I hit enter!
4
votes
1answer
127 views

Indentation in REPLs

I can't seem to get indentation working properly in the REPLs I've used so far (IELM, MIT-Scheme, and Python). Suppose I type the following and RET: ELISP> (defun something () _ My cursor ends ...
0
votes
1answer
168 views

Is there any way to get tabs to align relative to the previous line?

Currently I have this javascript code in a js2-mode buffer after I press tab: const entries = state.get('entries') .concat(getWinners(state.get('vote'))); and I would like for it to look ...
0
votes
1answer
66 views

Org mode flashes indentation of lines with parentheses

I've been having some issues using org-mode with paren matching. Here are a few screenshots of the problem. In short, when my mouse isn't on a line, the line is shown correctly, but when parenthesis ...
4
votes
1answer
1k views

Trouble adjusting tab-width

When I write Python code, I personally prefer indenting with 4 spaces instead of a tab. However, in my day job I work with a codebase that uses only tabs. When I open one of these files in emacs, ...
5
votes
1answer
686 views

How to change lisp mode indentation style

I'm not a lisp programmer. But I'm an emacs user, so I use elisp from times to times to do simple scripting. I'm not familiar with lisp style and I'm quite incompatible with it. Default indents ...
8
votes
1answer
207 views

Indentation in square brackets

Yet another question about indentation in AUCTeX... I would like to be able to indent content inside square brackets [...]. It would be useful for tikz option lists, for example, or trees drawn using ...
1
vote
1answer
269 views

How to have c-offset style correctly detect a Java constructor and change indentation?

Currently my team (non-Emacs users) indent java like so: public DiskThresholdDecider(Settings settings, NodeSettingsService nodeSettingsService, ...
2
votes
2answers
191 views

Added spaces between function arguments

I'd like to transform: function arg(a,b,c){} to function arg( a, b, c ){} Is there a way to do this or set it as part of c style auto indentation? So it will happen when editing JavaScript, C++, ...
6
votes
1answer
85 views

Indentation of list constants

Emacs' indentation of Emacs lisp code is really great, except for one thing: (defconst one-to-ten '(one two three four five six seven eight nine ...
2
votes
2answers
95 views

Modifying AucTeX bracket indentation locally

I am currently using songs package, which via some TeX trickery uses escaped brackets to mark chords (for example \[G] is G-major, while \[a] is a-minor). This causes problems with indentation, for ...
3
votes
1answer
84 views

Indenting specific environment deeper in AUCTeX

Is it possible to encourage AUCTeX to indent specific environment contents deeper than other environments? My specific case is getting the following indentation for chorus: \begin{song} \begin{verse} ...
3
votes
1answer
318 views

Auto-indent without creating indentation in empty lines

Is there a way to use auto-indentation in Emacs without creating indentation on empty lines? For an example from C, if I have if (true) { printf("word"); } and then insert a newline after the ...
1
vote
1answer
207 views

How to reduce enum definition indentation?

With my actual configuration, an enum definition looks like this: enum Toto { foo, bar } Spaces are by packs of 4 instead of 2 because I set 4 as default indentation space ...
0
votes
2answers
263 views

extraneous stars when using org-indent-mode

Since a recent update from the org-mode repository, if I turn on org-indent-mode, all lines show up indented with stars rather than spaces. Here's an example of how it looks: Here's the file without ...
7
votes
2answers
939 views

Indent with 4 spaces, but display 2

At work, we have a policy which states that we have to use 4 spaces for indentation, and in my opinion it makes the code harder to read. Is it possible to indent with 4 spaces, but display it as 2 ...
3
votes
2answers
768 views

Word wrap that preserves indent from previous line

This may really be a basic emacs lisp question, but I'm just starting to learn some Clojure -- tiptoeing along the first steps of the newbie's path -- and don't know any elisp yet. How can one set ...
7
votes
2answers
944 views

Commented lines shoot off to column 32 in octave-mode

I am using the octave major mode for editing my MATLAB code, since it is more convenient than the unsupported MATLAB packages for emacs on the internet. One downside is whenever I try to auto-indent ...
1
vote
1answer
48 views

indent text up to the start of the first word of the previous line

When entering text I sometimes want the indented. Is there a way to avoid having to type blank characters up to the point where the first word on the previous line starts?
2
votes
1answer
160 views

AUCTeX: prevent indentation inside commands

I am not a fan of the way AUCTeX indent LaTeX code. Some time ago I asked for help in disabling indentation. The solution provided there handles the large majority of my needs, but fails to prevent ...
9
votes
2answers
464 views

How can I write [0,1) in LaTeX mode without breaking indentation?

When writing LaTeX using latex-mode, I often want to write "half-open intervals" in my text. For instance, [0,1), which refers to the set of all numbers x with 0 <= x < 1. Unfortunately, ...
3
votes
0answers
57 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:...