Stack Exchange Network

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

2
votes
3answers
218 views

How to automatically set indent width (e.g. c-basic-offset) based on edited file?

I often work on several different codebases that use different indent styles (2 spaces vs 4 spacces vs tabs...). It is annoying to set c-basic-offset (or other variables, depending on mode) each time ...
1
vote
1answer
89 views

Extra indents in adaptive-wrap mode only for lines beginning with \item

When using the adaptive-wrap mode in the plain latex-mode (no AUCTeX), I want to give extra indents to only lines beginning with "\item". For example, I currently have: \begin{itemize} \...
1
vote
1answer
526 views

Variable-pitch face breaking indentation in org mode

I want to use a variable pitch face when using org mode (for composing articles, prose, etc.) The emacs wiki suggested using buffer face mode with a hook to set the face for org mode buffers: ;; Use ...
0
votes
1answer
88 views

Stop automatic indentation and cursor movement while typing in major mode

I've put together a simple major mode for syntax highlighting and indentation of AQL. This is my first, and I'm open to any suggestions there, but my question is more specific: When I type two ...
2
votes
1answer
111 views

Disabling hanging indentations with fill-paragraph

I want to be able to fill a whole paragraph with fill-paragraph, first line included, between the left-margin and fill-column values (adaptive-fill-mode is disabled). I am able to do this, but I ...
0
votes
1answer
499 views

tab and spaces shown aligned in emacs C++ mode, but not in other editors

In Emacs' C++ mode, I sometimes accidentally introduced a tab where I should use four whitespaces instead to create indentations. Adjacent lines with mixed uses of tabs and spaces for indentations are ...
0
votes
1answer
68 views

What is the best way to redefine the indentation rules of a major mode

I am using js-mode in emacs 25.1. There are some indentation rules that are not editable through the provided customization variables. The specific one I have issue with is the indentation of arrow ...
5
votes
1answer
515 views

Indent javascript arrow functions like regular anonymous functions

Using Emacs 25.1 and js-mode for javascript editing. Is it possible to change the indention rules in js-mode to customize the indention of arrow functions? Example of anonymous function indention: ...
1
vote
0answers
31 views

Line break and indentation in AucTeX [duplicate]

I am using AucTeX in combination with visual-line-mode but sometimes I find it somewhat confusing that a broken line does not follow the "current indentation" which makes it harder to see environments....
3
votes
2answers
614 views

How can I disable indentation rules within docstrings in python-mode?

When writing within docstrings in python-mode, I'm only able to tab/indent deeper than the leading edge of the string. For example: def foo(): """ | | << the only places I can "tab" to. ...
0
votes
1answer
39 views

Can I remove the indentation in {reftex-toc}?

I am new user of auctex/reftex and the reftex-toc-function is brilliant. However, on my small screen a lot of space is wasted when I have a document with only chapters, or even sections. (I put the ...
4
votes
1answer
607 views

How to turn off alignment-indent after line continuation in Shell-script mode?

In Shell-script[sh] mode, Emacs defaults to this style of indentation: /this/is/an/example/command/broken/over_multiple_lines which \ causes \ ...
3
votes
1answer
104 views

Web-mode + Dust.js, no indentation?

If I go to scratch, M-x web-mode RET, type in this snippet: <script type="text/x-dust-template"> {#obj_to_iterate} {prop} <----- this should indent {/obj_to_iterate} </script&...
3
votes
1answer
256 views

Is it possible to achieve erlang formatting like this?

As I was going through learnyousomeerlang I came across code formatted like so: if X > Y -> a() ; true -> b() end Presently As close as I can get is: if X > Y -> a() ; -...
1
vote
1answer
57 views

How to retain selection after command run (indent-code-rigidly)?

I found a neat code snippet for ~/.emacs configuration: (global-set-key (kbd "C->") (lambda (b e &optional n) (interactive "r") (...
1
vote
2answers
394 views

How to fix indentation that I do not like?

I love emacs and its modes but sometimes I do not agree with its indentation. In this specific case I am talking about glsl-mode . When I type an array inside a function, I want the square brackes to ...
1
vote
0answers
298 views

Modifying auto-indent in emacs with python

I often write python code in which a function returns a value. Often I will define that value higher up in the code as "returnvalue" or some similar name. Then the next line is indented ...
0
votes
1answer
733 views

Delete 4-spaces as a single tab

I asked another question yesterday but this bothers me a little. I use 4 spaces as indentation for programming (ShellScript, C and Python, mostly). When I want to delete the 4 spaces, I had to do one ...
9
votes
3answers
4k views

Set indentation for shell script function

I am trying to set the number of spaces per indent for starting a new function in sh-mode (bash sub-mode). I have tried setting: '(sh-basic-offset 2) '(sh-indentation 2) '(smie-indent-basic 2) (as ...
1
vote
0answers
126 views

Web-mode javascript indentation for “if” and “for”

When writing Javascript, I always put curly brackets after if in a new line, like this: if(a == 0) { .... But when I do that in web-mode, the default is like this: if(a == 0) { .... ...
2
votes
0answers
70 views

Fixed indentation for sectioning commands

I'm looking for a particular LaTeX indentation feature regarding sections, subsections etc. Specifically, I would like to start the text within a section (assuming \section is the highest sectioning ...
0
votes
1answer
92 views

How to see the implementation of the auto-indent procedure?

I want to inspect the lisp code that handle auto-indentation. By "auto-indent" I mean the indentation that automatically puts the beginning of a line at the right position in files such as .c, .cpp, ...
0
votes
1answer
488 views

Change indentation variables inside of buffer

I personally use 2 spaces for indentation but everyone has a preference and I'd like to respect that. When I open someone else's files I would prefer to use their indentation scheme. In my .emacs file ...
0
votes
1answer
130 views

Why is emacs indenting with tabs even though indent-tabs-mode is nil?

In C/l-mode F1 v indent-tabs-mode prints: indent-tabs-mode is a variable defined in `C source code'. Its value is nil Original value was t Local in buffer nir_types.cpp; global value is t But ...
6
votes
1answer
2k views

How to set indent to 4 spaces in nxml-mode?

I wanted to indent my XML files with 4 spaces. I tried to google it, and found this and this one. But they seem pretty old and/or didn't help me. This post is great about how to pretty print XML ...
1
vote
1answer
76 views

How to make tab key shift test after cursor in evil mode insert state

To be honest, I'm very novice in Emacs, so is it possible somehow to bind TAB key in insert state of evil mode to shift text after the cursor right on current indentation amount of spaces at each key ...
0
votes
1answer
508 views

How to get two space indentation for JS/JSX?

Expected behavior (demonstrated in vim): http://zc.d.pr/1a7b1/2p5XiuwX I expect hitting Enter should indent the pointer at the correct level with two spaces in, matching the surrounding syntax, ...
1
vote
1answer
66 views

What's the name of the auto indent code?

What's the name of that feature that auto indent the code when I press tab (Even fi the indentation is more to the right, the tab "erases" the abundany spaces) and how can I change the size of it?
2
votes
2answers
692 views

Tab always indent even in evil normal mode?

For code editing, and maybe other things too (but not for modes where the tab key has a special behaviour, notably org-mode), I want the tab key to indent, even when in evil normal (or motion) state. ...
0
votes
1answer
464 views

Getting proper indentation for Python Flask templates

I've started using the Flask Python framework, and I'm having trouble getting indentation to work properly in the template .html files. I use web-mode, and it seems to really not want me to indent ...
1
vote
1answer
162 views

How to indent php delimiter in php-mode?

php-mode is not indenting delimiter: <?php // Not indenting PHP delimiter if (true) { echo 'foo'; } How to indent delimiter? <?php // Indenting PHP delimiter if (true) { ...
3
votes
1answer
898 views

C brace indentation

I am new to Emacs and trying to learn the basics. I am writing a few C programs and I noticed that the default brace indentation is as follows: for(i = 0; i < 10; ++i) { // code }...
1
vote
1answer
993 views

How to indent with tabs in php-mode?

I need to indent my code with (add-hook 'php-mode-hook 'php-enable-symfony2-coding-style) but using tabs for indenting (and spaces for aligning, see https://www.emacswiki.org/emacs/SmartTabs). ...
3
votes
2answers
292 views

inverse of 'indent-tabs-mode'

According to indent-tabs-mode, Indentation can insert tabs if this is non-nil. nil means indentation cannot use tabs. I need the opposite of this option, prevent indentation from using spaces as ...
5
votes
2answers
2k views

change python indent in a specific file

I have a piece of legacy code in Python that uses inconsistent tabs - 2 spaces in some instances and 4 in others. I have my defaults set in my .emacs file to use 4 spaces, but in this case emacs ...
5
votes
1answer
404 views

Whitespace-mode tab mark disturb my indentation

I encounter this issue when i set whitespace-style to (face tabs trailing tab-mark) and turn on whitespace-mode. When whitespace-mode is turned off, everything looks well: When whitespace-mode is ...
2
votes
1answer
194 views

How can I setup the tab indentation size for ***-mode (Rust, Python, Ruby, etc)?

I have rust-mode installed on my Emacs 24.4. The tab indentation I have is 2 whitespaces, however in Rust mode it's different. I want to setup the tab indentation size for rust-mode, how can I do ...
2
votes
1answer
704 views

Minor mode for editing ansible playbooks

I have recently started using ansible, and yaml-mode seemed the logical choice for editing playbooks. However, the indentation does not quite work correctly. For example, I might start a task ...
6
votes
2answers
139 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
202 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
624 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
285 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
673 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
266 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
91 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
149 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
141 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
212 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
76 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 ...