Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I keep Visual Studio from indenting newlines (C#)?

Here's a gif of what's happening. I am pressing Enter twice. I don't want the indentation that gets created after I press Enter the second time.

EDIT: To be more precise, I do want to keep smart indentation to match newline indentation to the current block, even when new blocks are created. What I don't understand/like is the way it is adding indentation when that block was not ever indented that far to begin with. So I don't want Visual Studio to relatively indent newlines; it's not like I want to remove automatic indentation entirely.

like image 526
Hunter Avatar asked May 28 '18 04:05

Hunter


People also ask

How do I block indent in Visual Studio?

Visual studio's smart indenting does automatically indenting, but we can select a block or all the code for indentation. Use either of the two ways to indentation the code: Shift + Tab , Ctrl + k + f .

How do I turn off auto align in Visual Studio?

The solution was to go to 'Tools > Options > Text Editor > Basic > VB Specific' and turn 'Pretty Listing' OFF.


1 Answers

Tools - Options - Text Editor - C# - Tabs - Indenting

Set the value to None from Smart. Bear in mind this will drop your indentation to the start of the line, no tabs or spaces until you place them in yourself. This can cause headaches in the long run having to indent yourself, so you can just disable it once you move on and go back to you automated indentation.

It's not perfect, and according to everyone that uses visual studio you aren't alone in your complaints of indentation.

Please see this question if you want to know what I mean. Very messy.

like image 124
James Whyte Avatar answered Sep 22 '22 17:09

James Whyte