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.

4
votes
0answers
375 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 ...
5
votes
2answers
733 views

Auto indent plain list content?

When I make a plain list like this: - Pizza making This is an elaborate process that involves many years of training. Usually I have to manually press TAB on every new line. Can this be ...
0
votes
1answer
232 views

Debugging Tab command in emacs, js2-mode

Tab press in js2-mode goes to indent-for-tab-command in indent.el. This command takes a prefix argument as arg. Since no prefix arguments are set by C-u, what gets passed here? And internally, ...
4
votes
1answer
253 views

Emacs wrongly indent else expression in Python code

Say, I got a simple Python code snippet: def demo(i): if(i): print "True" else: print "False" I make indent-region for the whole buffer after save using before-save-hook in ...
0
votes
1answer
832 views

Using TAB key for indentation in Python REPL produces strange indentation problems

I'm using the Python REPL in a comint window via the run-python command, and I'm seeing bad behavior when I use the TAB key to do my indentation. For example: >>> for i in range(3): ... ...
1
vote
2answers
741 views

Is there a mode to indent doxygen type comment block with function parameters?

Consider the following php function: public function test(array $a, SomeObject $b) { return 0; } I would like to automatically generate the following code block: /** * @param array $a * @...
1
vote
1answer
222 views

why is emacs indenting when I type an open paren

I'm very new to Emacs and I like it so far, but there is one thing that has been bugging me. Its auto-indenting has been acting pretty random. Whenever I am on a new line and type something like: ...
4
votes
2answers
479 views

Configure indentation logic to ignore certain lines?

I am using outshine to organize my code (verilog/systemverilog language). Here is an example use: // * Class definition class my_class extends my_base_class; // code .. // ** Task 1 ...
2
votes
1answer
320 views

How to get correct indentation for the closing parenthesis in cperl-mode?

I have problems with correct alignment of the closing parenthesis in cperl-mode. For example consider the following Perl code: my $a = func1( Module::test() ); my $b = func2( test() ); my ...
2
votes
2answers
1k views

C++ Incorrect Enum Indentation

It seems like cc-mode indentation is working rather well, however I seem to have run into a minor issue when creating a few enums in C++. Emacs seems to handle almost all kinds of enums rather well ...
2
votes
0answers
119 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: ...
2
votes
1answer
571 views

Tab indentation for kernel editing

I am working on a Linux driver, and I would like to use emacs. My problem is that indenting does not work, no matter what. by this, I mean that when I press enter from a line, it goes at the beginning ...
1
vote
1answer
711 views

How to have emacs format/indent javadoc comments correctly?

Very new to emacs. (I only started day before yesterday.) I'm writing some Java and was wondering if there's an option or something I can set up so it will indent Javadoc comments correctly. What I ...
12
votes
4answers
2k views

How to customize org-mode indentation?

this question actually arises because I like to use non-monospaced fonts, (Sabon, Minion, Garamond, etc.) This cause a problem when use org-indent-mode, since the text under the headlines are now not ...
3
votes
3answers
1k views

Fixing forced indentation in shell-script-mode for tcsh

How do you configure the indentation to work correctly for tcsh shell scripts? I am unable to make the indentation work correctly when I use the shell-script-mode as it is. Problem: An indentation ...
1
vote
1answer
497 views

Haxe-mode broken in Emacs 24.4

Installing Emacs 24.4 broke my haxe mode. The mode for the HaXe language doesn't seem to be maintained any more so I'm trying to fix it myself. Firstly, I had a cl-macroexpand-all problem which ...
34
votes
2answers
17k views

How to disable auto-indentation of new lines?

I've recently upgraded emacs to version 24.4.1 and something has changed in the indentation of new lines. When I hit enter I expect just "bare" new line character at point where cursor was present, in ...
10
votes
3answers
2k views

How to auto-format the source code block in org-mode

When I'm using org-mode to take notes about a book, sometimes I'll copy/paste some code snippets into the note file. After pasting it, I'll 1. `C-c '` to call `org-edit-special` 2. `C-x h` to mark ...
2
votes
1answer
344 views

Emacs indent with tabs to 2 columns

Current with C, Javascript, Ruby, etc. when inserting a block with { <RETURN>, Emacs automatically indents the next line, but it does so with spaces. How do I change this behavior to tab ...
1
vote
1answer
2k views

Customizing a default indentation style for C++

I use the default style linux (snippet from here) ;; set indentation style linux for c++ (setq c-default-style "linux" c-basic-offset 4) But I can't get it to work with the style setting ...
12
votes
1answer
162 views

Auto-Indenting \if statements with AUCTeX

The current AUCTeX behaviour for primitive tex code involving if-like statements is to indent the conditional statement at the same level as the surrounding condition. I.e. code such as \if@...
12
votes
2answers
4k views

Better indentation and navigation in assembly source code

When I write C or Java code it's extremely regular, but with assembly (asm-mode), it's so disorganized. I'm using auto-complete and yasnippet. I created snippets and am using them, but the code ...
2
votes
1answer
206 views

How to determine which variable controls indentation offset for any given mode

Each major mode seems to (quite unfortunately) have its own naming conventions for the special variable used to control indentation level. For example, c-mode has c-basic-offset, python-mode has ...
6
votes
2answers
548 views

Do not align nested calls when using ruby-smie

When using the newly added ruby formatting functionality I face the following problem: I would really like for my rspec code to be formatted like the following: it do is_expected.to match(/\[Error\...
7
votes
1answer
3k views

“Format Code” like in Eclipse

In Eclipse, I can hit CTRL + SHIFT + F which not only corrects the indentation but also whitespace (for example: c=a +b ; is corrected to c = a + b;) and the line length. I am looking for a similar ...
3
votes
1answer
224 views

Make `return` key more powerful

Normally return key is just newline, I believe a lot of people bind it to newline-and-indent, but return is relatively common used key, the C-u RET and C-- RET basically do nothing but same as return, ...
4
votes
2answers
467 views

Indentation of newlines

I am writing source code and a lot of times I need to press Enter and have the newline indented with 4 spaces more than the previous. As I don't want to do it always, I would like to be able to use C-...
3
votes
1answer
891 views

Indented multi-tiered lists (and headings), with org-indent-mode?

I am new to Emacs, using it to structure text/ideas. After enabling word wrap from the menu and doing M-x org-indent-mode, I would like my document to look like this (the returns in the middle of ...
3
votes
1answer
366 views

Python and aggressive-indent

I am trying to use aggressive-indent, which I find great, but when I am writing Python code it doesn't seem to work (although general it works fine). I may miss something in the usage of aggressive-...
2
votes
1answer
99 views

Move cursor with respect to indentation

Is there any way to enable the following behavior. Let's say i have some code: def main(args: List[String]): Unit = { } Of cause the blank line between braces is indented, but when i move cursor to ...
4
votes
1answer
289 views

Customize newline-and-indent function

I'd like to extends this function to work as usual in most cases but if current line starts with * then it should indent and then insert *. Particularly i want to use it in multi line comments, i.e: /...
11
votes
1answer
1k views

Coloring indentation levels

Consider the following two snapshots: The first below is coming from Emacs on Python mode (with Jedi & Elpy) This second one below comes from manually photoshopping the previous one to make it ...
10
votes
1answer
3k views

python auto indent problem

I'm using Emacs 24.4. When writing Python code, Emacs behaves strangely with respect to indentation. For example: for i in range(10): print(i) for i in range(10) When I input :, Emacs adds a ...
6
votes
3answers
730 views

Customizing c-mode indentation behavior in Emacs 24.4

Before Emacs 24.4, indentation in c-mode happened after typing things like ;, , and so on and I like this behavior. But in Emacs 24.4, c-mode also indents on RET. This causes a lot of problems for me ...
4
votes
4answers
773 views

Repeating a command n times

For posting code to stackexchange I repeatedly have to do indentation in emacs. I mark a piece of text and then do M-X indent-rigidly four times. Is there an elegant way to do this indentation of text ...
3
votes
1answer
576 views

Modifying Java indentation style

I use Emacs for Android development and this has been bugging me lately. I'm trying to get the following indentation behaviour: submitBtn.setOnClickListener(new OnClickListener() { @Override ...
14
votes
1answer
2k views

How to indent items in LaTeX/AUCTeX itemize environments?

Q: how can I get "proper" indentation of LaTeX itemize environments in auctex? Here's where I'd like to be with an item in an itemize environment: \item line is indented two spaces relative to the ...
9
votes
2answers
942 views

Customizing indentation in makefile mode?

In my makefiles, I prefer the following indentation for continuation lines: FILES:= \ file1.cpp \ file2.cpp \ fileYetAnother.cpp LIBS:= \ ...
4
votes
3answers
464 views

Dumb indentation

I want to force Emacs to do (quasi-)dumb indentation à la Eclipse. By this I mean the following: If the point is at the beginning of a line and I press tab, force shift the line 2 spaces to the right....
2
votes
2answers
2k views

Indentation after braces in C

I don't know what the formal name of it is (this being one of the reasons that I can't find how to achieve it). But, what I want is to make Emacs start the second bracket with the same amount of space ...
5
votes
1answer
240 views

Some warnings and unexpected indentation with SMIE

I'm trying SMIE to describe the Nix language. Unfortunately when I use it, I have the following problems: There are 4 messages saying: Warning (smie): token } is both closer and neither. Which I do ...
1
vote
1answer
4k views

TAB does not auto-indent lines anymore

I used to have a configuration for TAB which was doing something like this : This is the code before hitting TAB. template<typename T> class A { }; // This is where I hit TAB The code ...
2
votes
1answer
182 views

How to indent back one level when writing a newline?

I'm using Emacs to write LaTeX. For example, in the following code, I have write to the level 3. When I press C-j, the cursor will indent to the third level. I what the newline to be indent at level 2....
10
votes
2answers
4k views

Make web-mode always indent with spaces

I am using emacs web-mode, and the tabbing in JS files seems to be acting strangely. I have tab set to indent 2 spaces, but when the indent reaches 8 spaces, web-mode turns them into a tab, and then ...
1
vote
2answers
806 views

Why does hook to set up C++ mode indentation not work?

This is my code (defun my/set-c-mode () (local-set-key (kbd "C-c C-c") 'compile) (setq compilation-finish-function 'compilation-exit-autoclose-clone) (setq c-default-style "linux") (setq c-indent-...
10
votes
2answers
695 views

Is there an Emacs mode convenient for writing poetry?

I've tried simple searches on Google and MELPA with keywords like "emacs poetry mode" or "emacs verse mode" but haven't found anything specifically built for the purpose. The manual walks through ...
4
votes
1answer
390 views

ESS indentation of parentheses after =?

Indentation in ESS is occasionally a little kooky, and I'm trying to figure out if the kookiness is a bug or a feature. How does one get proper indentation of parentheses after an "=" sign in ESS (...
5
votes
1answer
223 views

Get Emacs to indent fluent builder inside argument list

So emacs's java-mode handles indenting continued method invocations at the function body level out of the box, but it doesn't seem to handle them inside of an argument list. I'd like to override this ...
4
votes
1answer
481 views

How to configure specific Java indentation?

I have the following code from Intellij's indentation: public static String[] defaultMethodBlacklist = new String[]{ "getClass", "wait", "notify", "notifyAll", ...
17
votes
4answers
984 views

Automatically re-indenting elisp code when adding or removing code before an indented block

Say I have a elisp code like: (+ 2 3▮(+ 3 4)) Is there a way to automatically re-indent the sexp after the cursor, when I add or remove symbols? So after pressing SPC 4 SPC, I would ...