Questions tagged [auto-indent]

Auto-indentation is used in programming tools (IDEs and source code beautifiers) to automatically adjust the amount of leading white space on a line.

Auto-indentation is used in programming tools (IDEs and source code beautifiers) to automatically adjust the amount of leading white space on a line. In certain programming languages, such as Python, Haskell, and Occam, indentation is crucial for to demarcating the programming structure, and so auto-indentation plays an important role in facilitating this.

365 questions
1331
votes
11 answers

Tab key == 4 spaces and auto-indent after curly braces in Vim

How do I make vi-Vim never use tabs (converting spaces to tabs, bad!), makes the tab key == 4 spaces, and automatically indent code after curly brace blocks like Emacs does? Also, how do I save these settings so I never have to input them…
mmcdole
  • 86,293
  • 60
  • 181
  • 221
1318
votes
24 answers

Turning off auto indent when pasting text into vim

I am making the effort to learn Vim. When I paste code into my document from the clipboard, I get extra spaces at the start of each new line: line line line I know you can turn off auto indent but I can't get it to work because I have some…
Rimian
  • 32,654
  • 13
  • 106
  • 109
672
votes
9 answers

How To Auto-Format / Indent XML/HTML in Notepad++

Is there a way to re-indent a block of code? I'm looking for something similar to Ctrl+Shift+F in Eclipse (Auto-Format/Indent). To be clear, I already know how to format XML outside of Notepad++ (Eclipse works fine, as mentioned) so I don't need a…
SBoss
  • 8,255
  • 6
  • 25
  • 44
408
votes
11 answers

How to auto-indent code in the Atom editor?

How do you auto-indent your code in the Atom editor? In other editors you can usually select some code and auto-indent it. Is there a keyboard shortcut as well?
Anders
  • 9,518
  • 7
  • 25
  • 34
233
votes
10 answers

How to fix/convert space indentation in Sublime Text?

Example: If I have a document with 2 space indentation, and I want it to have 4 space indentation, how do I automatically convert it by using the Sublime Text editor?
Magne
  • 14,749
  • 8
  • 57
  • 77
206
votes
11 answers

Sublime Text 3, convert spaces to tabs

I know there are a lot of posts about this, but I couldn´t get it to work. I use tabs for coding. Is there a way, to convert always spaces to tabs? I.e. on open and on Save files? Anyone got an idea? // edit: My desire is to do this automatically!…
chris
  • 4,555
  • 5
  • 30
  • 53
95
votes
4 answers

Difference between Ctrl+Shift+F and Ctrl+I in Eclipse

I have been used Ctrl+Shift+F to correct indentation but I heard there is another shortcut to do that: Ctrl+I According a reference found in google, Ctrl+Shift+F is Reformat and Ctrl+I is Correct indentation. Is there any difference between them? or…
RENO
  • 1,235
  • 1
  • 9
  • 10
78
votes
5 answers

Custom Brace formatting with Resharper

I'm using Resharper 4.5 and I need custom formatting of braces when writing an array or object initializer. Resharper supports some styles: Gnu Style: int[] array = new int[] { 1, 2, 3 …
Hadi Eskandari
  • 23,473
  • 7
  • 48
  • 64
54
votes
4 answers

How to get gedit to auto-indent code

I'm trying to get gedit to auto-indent my code. The auto-indent check-box in preferences doesn't work. Is there a way to get gedit to auto-indent code? (By the way, I only really care about C++ indentation. I don't need indentation for any other…
Linuxios
  • 31,993
  • 12
  • 82
  • 110
54
votes
6 answers

Brackets.io: Is there a way to auto indent / format

I am new to Brackets.io and thought I saw a shortcut key to auto indent/format HTML, however I cannot find a shortcut. Is there a shortcut or add-on that will do this for me?
Zac Smith
  • 1,725
  • 1
  • 11
  • 13
43
votes
3 answers

How do I Change VSCode To Indent 4 Spaces Instead Of Default 2?

I have applied the below settings in VS Code to get 4 spaces indentation. But always when I open a new file, it switches back to 2 in the right-bottom corner. If I click in the right-bottom corner and change the setting back to 4, VSCode will…
43
votes
7 answers

How do I change the autoindent to 2 space in IPython notebook

I find that developing functions in IPython notebook allows me to work quickly. When I'm happy with the results I copy-paste to a file. The autoindent is 4 spaces, but the coding style for indentation at my company is 2 spaces. How do I change the…
user2826610
  • 433
  • 1
  • 4
  • 5
37
votes
7 answers

Notepad++: disable auto-indent after empty lines

I find the autoindent style of Notepad++ a little weird: when I am typing on an indented line, I do want it to indent the next line after I press Enter (this it does properly). However, when I am on an empty line (no indentation, no characters) and…
Laurent
  • 5,650
  • 13
  • 40
  • 58
36
votes
3 answers

How to auto indent a C++ class with 4 spaces using clang-format?

I got the next .clang-format file in my project's root directory: --- AlignTrailingComments: true AllowShortFunctionsOnASingleLine: false AllowShortIfStatementsOnASingleLine: true AllowShortLoopsOnASingleLine: true BreakBeforeBinaryOperators:…
BPL
  • 9,807
  • 7
  • 37
  • 90
34
votes
8 answers

Indent/format code in Visual Studio code on MAC

i'm trying to indent my code in visual studio code. I searched and i found that ctrl + F + K should be work, but it doesn't. I tried cmd + k + f too, but it still not working. I hope you can help me!
Steph8
  • 1,173
  • 2
  • 14
  • 30
1
2 3
24 25