<aside> 🌐 https://ghostscript.com/r/Visual-Studio-Tweaks

</aside>

Visual Studio Tweaks

This page documents some tweaks to Visual Studio that I find very useful.

These are primarily targetted at VS2019, but many work with older versions too.

Whitespace.

Trailing whitespace visualisation

Extensions -> Manage Extensions -> Search for Visualize Trailing Whitespace

Install that, restart VS. Any trailing whitespace (other than the line you are currently editing) shows up as red.

You can edit the color in Tools -> Options -> Environment -> Fonts and Colors -> Text Editor -> Trailing Whitespace.

Removing trailing whitespace

Extensions -> Manage Extensions -> Search for “RemoveTrailingWhitespaces”.

That will give you a menu option to remove trailing whitespace from a file (Edit -> Advanced -> Remove Trailing Whitespace).

It can be set to run automatically whenever a file is saved (Tools -> Options -> Remove Trailing Whitespaces -> Options -> Remove trailing whitespace on save = true).

Visualizing Tabs vs Spaces

Tools -> Options -> Text Editor -> General -> Display -> Tick “View whitespace”.

This causes tabs and spaces to appear visibly. I find the default setting for this to be a bit too visible for my taste, so I also set: Tools -> Options -> Environment -> Fonts and Colors -> Text Editor -> Visible White Space - > set foreground to silver.

That makes whitespace visible enough, but not glaring.

Guidelines.

I like to know when my lines are getting past 72 (and at a push, 80) chars.

I use an extension to add ‘guidelines’ to the display for this. Extensions -> Manage Extensions -> Search for “Editor Guidelines”. Details of how to configure it can be found here.