Reputation: 99408
I am working on someone else's C# source files in Visual Studio 2015. Here is how I use indention in the IDE:
When I hit return key to create a new line, the IDE automatically add indents to the new line.
Some other times, I select a region of multiple lines, and click menu "Edit -> Advanced -> increase/decrease line indent".
That creates a mixed use of tabs and four space combinations in the same source file, probably because the original author of the source files used different way to indent lines in their Visual Studio than I do via the IDE.
I wonder how I can make it consistent to use either tabs or four spaces for indenting every line, instead of mixing them in the same source files?
I followed https://msdn.microsoft.com/en-us/library/ms165330(v=vs.90).aspx, but couldn't find out if there is a setting for me to solve my problem.
Upvotes: 0
Views: 604
Reputation: 429
Visual Studio has an Adaptive Formatting behavior which the Editor heuristically determines if the current file should use Tabs or Spaces for indentation.
You can turn this behavior off by going to Tools > Options > Text Editor > Advanced
and uncheck “Use adaptive formatting”.
Upvotes: 0
Reputation: 4784
Try pressing
CTRL-K-D
It will properly indent all the code in your file
You can change the indent size, and a bunch of other things
Please check this link
Upvotes: 3
Reputation: 17004
Simple press the following combination (while holding CTRL):
CTRL + K + D
This will automaticly reformat your code.
Upvotes: 3