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.

1
vote
0answers
104 views

Prevent emacs to indent when yanking into html buffer

I have disabled electric indent mode, as specified here, but when yanking text, indenting is still performed. I am yanking text into an html buffer, and I do not want any change whatsoever to be ...
1
vote
0answers
58 views

Make backspace(+?) remove a level of indentation in ReST mode

I often find myself in the situation where ReST-mode has correctly identified that my last line can be followed by an idented line, but I want to continue on the next higher level of indentation. How ...
1
vote
0answers
485 views

setting csharp mode indentation to 2 spaces

Complete emacs/lisp newbie trying to switch from vim. I noticed that emacs indents C# files to 4 spaces, which is normally great, but I'm working on a project that requires 2 space indentation. I've ...
0
votes
1answer
60 views

Strange Errors in Python-Mode

I am using the python mode. When i try to evaluate the following def using C-M-x i get this error from the python interpreter which looks strange: def foo(*args, **kwargs): print args, kwargs &...
0
votes
1answer
102 views

Why is tab-width reset when I open a C++ file?

So I'm trying to setup default indentation in Emacs. Currently I have the following at the bottom of my .emacs file as per a number of tutorials I've found on the internet. (setq-default indent-tabs-...
1
vote
1answer
304 views

Emacs bad indentation

So I've decided to try emacs, and I find it really good. However, I'm mostly writing Python, so the indentation is a crucial thing for me. After couple of failures in configuring I've finally reached ...
5
votes
1answer
182 views

Docstrings don't automatically indent themselves in elpy-mode. How do I fix this?

This is an example function that shows that docstrings do not automatically indent. def testing_docstring(): """ docstring is not indented automatically! Even after a newline. """ ...
1
vote
0answers
151 views

How to indent a tex file like org-mode?

When I'm editing a org-mode file, the structure of mine is like this(you may need configuration in init.el): * A section This is the content of the section #+BEGIN_SRC lang code here #+...
2
votes
3answers
214 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
86 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
476 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
80 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 ...
0
votes
0answers
32 views

Space inserted at beginning of previous line when I hit `RET`

I hope I can make this clear: While I'm developing various Javascript files which are shared between my team and I, I've noticed that I get a space inserted at the beginning of the previous line ...
2
votes
1answer
104 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
476 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
490 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
550 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
38 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
558 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
103 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
238 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
56 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
373 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
279 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
670 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
3k 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
122 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
82 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
472 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
123 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
71 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
480 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
60 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
666 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
433 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 ...
0
votes
1answer
154 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
792 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 }...
0
votes
1answer
938 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
277 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 ...
0
votes
0answers
155 views

Disabling broken HTML auto-indentation

After a recent upgrade from Ubuntu 14.04 (Emacs 24.3.1) to Ubuntu 16.04 (Emacs 24.5.1), Emacs started to automatically indent my HTML files while I type them, each time I press the return key. This ...
0
votes
0answers
483 views

How do I prevent indentation of braces in function arguments with csharp-mode

I'm new to customizing Emacs, and I'm struggling to get csharp-mode's indentation to match Visual Studio's defaults (which my coworkers use). I'm starting from the defaults of the Spacemacs csharp ...
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
379 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
187 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
670 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 ...
0
votes
0answers
45 views

Turning on semantic-mode silently shadows tab key with complete symbol

Here is my problem: I have the TAB key bound to a function that indents code level and adjusts parens. It works just fine. But when I M-x semantic-mode, for some reason the TAB binding is shadowed ...