Showing posts with label formatting. Show all posts
Showing posts with label formatting. Show all posts

Friday, September 03, 2010

Visual Studio Formatting Settings

Here is a list of formatting settings that I like in Visual Studio.

View White Space
Edit -> Advanced -> View White Space
This allow me to see if I have tabs or spaces.

Also Edit -> Advanced -> Untabify Selected Lines

Place open brace on new line for functions and control blocks
In Visual Studio, click Tools -> Options. In the Options dialog on the left pane select Text editor -> JScript -> Formatting
See here for a picture.

Tuesday, December 22, 2009

Tabs or Spaces

Some programmers have strong opinions about whether to use tabs or spaces to indent code.
This is what I use. In Visual Studio 2017 choose
Tools\Options\Text Editor\All Languages\Tabs
Select Smart Indenting
Tab size and Indent size = 4
Select "Insert spaces"

If you use Shift+Tab when in front of 4 spaces, it will delete the 4 spaces the same as if you press backspace in front of a tab character.
To convert a file one way or another there is "Tabify Selected Lines" and "Untabify Selected Lines" under the Edit\Advanced menu.

View White Space

Use the following Menu in Visual Studio to view the white space characters
Edit->Advanced->View White Space
This allows you to see whether the white space is tabs or spaces.

For me these characters are too prominent. So I dim them by choosing
Tools->Options->
Environment->Fonts and Colors
Select "Visible White Space" from the Display Items.
Select Silver. Then Click the Custom Button and use the darkness scale to choose the right amount of darkness.

In Beyond Compare you can select the following from the View menu:
Show White Space
Ignore Unimportant Differences

They are useful when dealing with differences in white space.