Where are the settings to show a space
, tab
, paragraph
, CRLF
, etc. (extended) characters?
-
2If you happen to add a control character by mistake, or you suspect that there may be a control character causing you errors, my recommendation is to cut the suspected code section out, paste it in Notepad++, find and remove the culprit, then cut the code and paste it back into Visual Studio. This is the easiest way, and it works every time. So keep a copy of Notepad++ installed, just in case.– SamirCommented Jul 2, 2017 at 15:00
12 Answers
Edit > Advanced > View White Space. The keyboard shortcut is CTRL+R, CTRL+W. The command is called Edit.ViewWhiteSpace
.
It works in all Visual Studio versions at least since Visual Studio 2010, the current one being Visual Studio 2019 (at time of writing). In Visual Studio 2013, you can also use CTRL+E, S or CTRL+E, CTRL+S.
By default, end of line markers are not visualized. This functionality is provided by the End of the Line extension.
-
37This doesn't answer the original question fully. The question was about white space characters and new line characters (hence "CRLF"). This option does not show the new line characters.– AlexCommented Nov 12, 2014 at 6:44
-
8Is there an extension for VS 2019? End of the Line only supports up to 2017– KirCommented Jul 12, 2019 at 14:38
-
As of VS 2019 16.8.1 "Edit" -> "Advanced" has shrunk away to almost nothing. Which means it's either moved someplace else, or been removed. The keyboard shortcut
Ctrl
-R
,Ctrl
-W
still works, so at least it's still possible– dgnuffCommented Nov 13, 2020 at 3:19 -
@dgnuff Wait, what? I still have
Advanced
in VS 2019 v16.10.2 with about 25 options in it. Perhaps you've customized VS without realizing it? Importing a profile can do that, eg.||
Btw, it's amazing to look through the history of the edits to this answer. I think it's more Palec's than Fourth's at this point, at the expense of Pavel, whose answer Palec incorporated into this one in 2018. Weird.– ruffinCommented Jul 16, 2021 at 19:31 -
Great ! Is there a way to add this command as a button in a toolbar ? I can't find that option.– RogerCommented Mar 25, 2022 at 7:38
Edit -> Advanced -> View White Space
or Ctrl+R,Ctrl+W for Visual Studio 2019
-
28Thank you for providing the name and location of the menu item. Very annoying when people just give you keyboard shortcuts (which change from version to version and may differ by configuration). Commented Aug 12, 2015 at 13:18
-
6
-
2
-
9@Johnny_D it exists but you must have a file opened. If you have no files opened for editing, then you don't see the
Advanced -> View White Space
part. Commented Jun 22, 2016 at 13:13 -
Ctrl+R for me opens a search box and Ctrl+W closes a tab Commented May 30, 2023 at 2:48
Display white space characters
Menu: You can toggle the visibility of the white space characters from the menu: Edit > Advanced > View White Space.
Button:
If you want to add the button to a toolbar, it is called Toggle Visual Space
in the command category "Edit".
The actual command name is: Edit.ViewWhiteSpace
.
Keyboard Shortcut:
In Visual Studio 2015, 2017 and 2019 the default keyboard shortcut still is CTRL+R, CTRL+W
Type one after the other.
All default shortcuts
End-of-line characters
Extension:
There is a minimal extension adding the displaying of end-of-line characters (LF and CR) to the visual white space mode, as you would expect. Additionally it supplies buttons and short-cuts to modify all line-endings in a document, or a selection.
VisualStudio gallery: End of the Line
Note: Since Visual Studio 2017 there is no option in the File-menu called Advanced Save Options
. Changing the encoding and line-endings for a file can be done using Save File As ...
and clicking the down-arrow on the right side of the save-button. This shows the option Save with Encoding
. You'll be asked permission to overwrite the current file.
-
1That's what I needed, I could find the command name but when adding buttons there's no way to search for anything so it's a guessing game. Commented May 1, 2018 at 23:47
-
2
-
2@Felix sadly the extension hasn't been updated. It still works, but requires some manual edits, see the marketplace page and a comment from daixian. marketplace.visualstudio.com/…– FarwayCommented Nov 12, 2020 at 0:08
My problem was hitting CTRL+F and space
This marked all spaces brown. Spent 10 minutes to "turn it off" :P
If you use Visual Studio Code => View => Render Whitespace That's it! For me this setting was on, but didn't work. I had to turn it off and on again and than it worked! So this is a bug in Visual Studio Code!
If you use Visual Studio 2022 you can change the display options for whitespace etc. in Tools => Options => Text Editor => General and select "View whitespace"
-
-
I added this answers because I had the exact same problem, only Visual Studio Code didn't exist 11 years ago...– CerveserCommented Dec 6, 2022 at 19:46
-
The correct shortcut is CTRL-R-W
like you don't have to release CTRL button while pressing W. This worked for me in VS 2015
-
CTRL-R-W will close the tab and open a search box becasue Ctrl+R for me opens a search box and Ctrl+W closes a tab Commented May 30, 2023 at 2:51
For those who are looking for a button toggle:
The name of this command is View white space in GUI menu (Edit -> Advanced -> View white space).
The name of this command in the Add command popup is Toggle Visual Space.
For Visual Studio for Mac, you can find it under Visual Studio -> Preferences -> Text Editor -> Markers and Rulers -> Show invisible characters
Visual Studio for Mac 2019
You may need to restart Visual Studio for the changes to take effect.
Visual Studio for Mac 2022
You can enable this feature only for selected text, or always, and choose to show line endings, spaces and/or tabs. Changes will take effect immediately.
-
This is the dumbest design decision I have seen in VS. I usually only want to see the whitespace for a minute while I verify and fix tab/spaces etc. I don't want to see it all the time. I have to restart VS to see the whitespace? What idiot thought this was a good idea? Why didn't they do it like Windows?– PierreCommented Jul 30, 2020 at 20:03
-
You can report a problem for visual studio for mac using this link @Pierre: developercommunity.visualstudio.com/content/problem/… Commented Aug 1, 2020 at 12:43
-
Thank you for your constructive suggestion @Paiman Roointan. I have submitted to the Forum: developercommunity.visualstudio.com/content/problem/1139872/…– PierreCommented Aug 6, 2020 at 13:47
The shortcut didn't work for me in Visual Studio 2015, also it was not in the edit menu.
Download and install the Productivity Power Tools for VS2015 and than you can find these options in the edit > advanced menu.
-
1You can see them in the edit menu if there is a file open Commented Oct 28, 2016 at 8:21
For completeness since I haven't seen it mentioned here, it is also in Options->Text Editor->General->View Whitespace.