329

I don't know what I did but I don't know how to get rid of those arrows on the left.

alt text

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Juan
  • 15,274
  • 23
  • 105
  • 187
  • 7
    Well maybe it should say something about arrows because I didn't know what they were and people who want to get rid of them probably doesn't either (I don't think i'd Google "How to get rid of whitespace characters" unless I know they are whitespace characters and most likely already know how to get rid of them) – Juan Nov 02 '10 at 15:49
  • 7
    Actually, this just happened to me and I knew exactly what they were, but didn't know how to hide them, so I searched Google for "Visual Studio Hide Whitespace Characters" and this was the first result. So, thanks! – bubbleking Jun 08 '16 at 14:53
  • Unfortunately neither the keyboard shortcut(s) nor menu placement is intuitive. As a result I have googled this exact stack overflow post (via `visual studio show whitespace` dozens of times over the years when installing VS on a new machine at a new job. Summary: No, just knowing they are whitespace characters doesn't mean you know how to toggle them. – Assimilater May 24 '17 at 00:36

6 Answers6

646

CTRL+R, CTRL+W : Toggle showing whitespace

or under the Edit Menu:

  • Edit -> Advanced -> View White Space

[BTW, it also appears you are using Tabs. It's common practice to have the IDE turn Tabs into spaces (often 4), via Options.]

Mwiza
  • 7,780
  • 3
  • 46
  • 42
Mitch Wheat
  • 295,962
  • 43
  • 465
  • 541
  • 2
    hehe I toggled it on again by mistake XDDD Thank you!!! Anybody knows why this feature even exists? Isn't it infinitely annoying? – Vintharas Dec 13 '11 at 10:48
  • 1
    My god it was annoying, thanks for the tip. But it was also fascinating to see the number of tabs vs spaces inconsistencies we had in each file. – Mike Mooney Jul 11 '12 at 20:14
  • First I tried with Tools->Options->Text editor->Automatic delimiter highlighting. When it didn't help I started to google. Thanks for the answer. Anyway these settings aren't very intuitive IMO. – ka3ak May 21 '13 at 07:13
  • Seems like this feature is missing in Visual Studio 2013 Preview – Konstantin Tarkus Jun 28 '13 at 22:11
  • @mhenry1384 : There are good reasons to convert tabs into spaces. If you don't like it, don't do it. I think you will find the majority of developers convert tabs to spaces. – Mitch Wheat Nov 12 '13 at 22:43
  • 32
    @Vintharas: It exists because people like me keep it on ALL THE TIME, because we like always being aware of what we're inserting or how we're changing the file. Gives us more casual control over our environment. There are also cases where it's actually critical, such as inside strings that are getting parsed. – Thought Jul 06 '14 at 23:30
  • 3
    I find it useful because our coding standards prohibit any trailing whitespace so this allows me to see any. I am not able to install add ons to fix it for me as we use the Express version. – Stefan Aug 28 '14 at 07:43
  • 2
    Tabs are the best as when you backspace a tab you don't have to press backspace lots of times. – Matthew Lock Apr 01 '15 at 03:32
  • 3
    nvm. you use tabs. I'll use spaces. – Mitch Wheat Apr 01 '15 at 05:32
  • 1
    @MikeMooney old i know but python uses whitespace the same way most languages use `{ }` or statments. Worse yet tabs and spaces are not equivalent. So if you happen to be working on python in VS seeing whitespace is incredibly useful (especially when the code you edit isn't your own). I know VS wasn't natively made to support python, but it is definitely useful for this purpose – andrew May 19 '15 at 18:52
  • 1
    This option is missing in VS2013. Though shortcut key is working. (y) – IsmailS May 25 '15 at 12:11
  • 2
    @MatthewLock Shift+Tab is your friend. – CSPshala May 28 '15 at 23:49
  • 10
    @MitchWheat Seems to me that most developer disagree with you. I suggest you read their comments. It might change your minds about using tabs http://programmers.stackexchange.com/questions/57/tabs-versus-spaces-what-is-the-proper-indentation-character-for-everything-in-e – JSON Aug 03 '16 at 13:25
  • 1
    hitting the tab key and letting the IDE insert spaces is fine. You still don't have a tab char in your code. tabs are a relic of mechanical typewriters – Mitch Wheat Aug 04 '16 at 00:21
  • Leading tabs, trailing spaces, ftw @JSON Nice link :) – Assimilater Aug 18 '16 at 18:57
  • Actually, TABS seem to be more popular, at least among [SE users](http://softwareengineering.stackexchange.com/a/72/233721). Tabs have far more upvotes than spaces. The reasons that are given to use tabs are also far more logical. – mbomb007 Mar 01 '17 at 16:44
  • 2
    For users who have "view whitespace" turned on, spaces are horrible, but tabs are nice and neat, providing an easy indicator of indentation level. – mbomb007 Mar 01 '17 at 16:52
  • The menu option is available only while you are editing a code file. If the editor window is not active, toggling the view isn't available and VS complains "The key combination CTRL+R, CTRL+W is not available." @MitchWheat Tabs are decidedly not a relic. They save space and enable alignment of tabular data, hence the word "tab". – Suncat2000 Oct 25 '17 at 12:56
  • @Vintharas It's also critical in whitespace sensitive languages (e.g., Python, which is now officially supported, and you might have a make file if you're doing C++). – jpmc26 Feb 03 '18 at 07:48
  • Ctrl+R,W still good in VS 2019 Pro (and tabs rule spaces drool). – MrBoJangles Aug 07 '19 at 16:04
46

In Visual Studio 2010 the key sequence CTRL+E, S will also toggle display of whitespace characters.

Mwiza
  • 7,780
  • 3
  • 46
  • 42
Kellen Donohue
  • 777
  • 8
  • 17
  • I can confirm that this also works in Visual Studio 2013 Express. – jmstoker Jun 02 '14 at 21:00
  • 1
    Ah that's interesting. I couldn't work out in what universe I could possibly have pressed CTRL-R, CTRL-W by mistake; but CTRL-E, S seems a bit more plausible. – Carl Sharman Oct 07 '14 at 08:39
  • That must have been what I hit on accident when going to toggle some comments (`CTRL-E, C`, `CTRL-E, U`) – jocull Oct 30 '14 at 15:21
  • 2
    Or accidentally hitting E when trying to save with CTRL-S – DrDeth Nov 04 '14 at 12:27
  • There are different default keyboard mappings available. CTRL-E, S is the sequence in one of them. CTRL-R, W is the sequence in another. Giving any individual sequence, though, is futile because they are all changed by a different setting, and can in any case be overridden. – ClickRick Oct 28 '22 at 14:09
9

If the Toggle Visual Space icon shall be added to a Visual Studio toolbar of your choice, because it shall be turned on and off via mouse click, then follow this instruction:

  1. Customize the desired toolbar

  2. Click on Customize...

  3. Click on Add Command...

  4. Go to Edit and chose Toggle Visual Space

  5. Click on OK

Tested with Visual Studio 2019 as well as Visual Studio 2022.

CKE
  • 1,533
  • 19
  • 18
  • 29
  • 2
    That's what I was looking for - the wording that's used in that dialog, so I can add it to a toolbar rather than having to remember a key sequence! – ClickRick Oct 28 '22 at 14:11
  • 1
    interesting, how I was suppose to find the button in this "add command" window? There are no search by name, and in the Edit/Advanced it is called "view white space" – yalov Jul 18 '23 at 12:55
7

In Visual Studio 2015 From the top menu

Edit -> Advanced -> View White Space

or CTRL + E, S

Mwiza
  • 7,780
  • 3
  • 46
  • 42
Max Carroll
  • 4,441
  • 2
  • 31
  • 31
  • There are different default keyboard mappings available. CTRL-E, S is the sequence in one of them. CTRL-R, W is the sequence in another. Giving any individual sequence, though, is futile because they are all changed by a different setting, and can in any case be overridden. – ClickRick Oct 28 '22 at 14:10
3

for VS code and later versions Ctrl + P to open and then writing Whitespace, you can select the View: Toggle Render Whitespace

Nick P
  • 31
  • 2
2

CTRL+SHIFT+* is the de-facto standard key combination for showing/hiding whitespace characters in all Microsoft products that support this feature.

P.S: * refers to 8- * key, not to numeric keypad * key.

AnT stands with Russia
  • 312,472
  • 42
  • 525
  • 765