Show space, tab, CRLF characters in editor of Visual Studio - visual-studio

Where are the settings to show a space, tab, paragraph, CRLF, etc. (extended) characters?

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.

Edit -> Advanced -> View White Space or Ctrl+R,Ctrl+W for Visual Studio 2019

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.

My problem was hitting CTRL+F and space
This marked all spaces brown. Spent 10 minutes to "turn it off" :P

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

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.

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"

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.

To see the CRLF you can try this extension: End of the Line
It works for VS2012+

For Visual Studio for mac, you can find it under Visual Studio -> Preferences -> Text Editor -> Markers and Rulers -> Show invisible characters
Please note you may need to restart Visual Studio for the changes to take effect

For completeness since I haven't seen it mentioned here, it is also in Options->Text Editor->General->View Whitespace.

In the actual version this Option ist under Editor: Render Whitespace

Related

In Visual Studio, what is the keyboard shortcut and Command ID to "search/query everything box"

In Visual Studio 2021 or above what is the keyboard shortcut (KeyMap) Command ID to the "search everything box"? This box is displayed top right of IDE menu bar. It offers a global search including, IDE actions, menus, commands and symbols within code.
The default Ctrl+Q is NOT assigned on my config, used for something else.
Please see the screenshot:
Could not find the correct command in KeyMap. For information, in JetBrains Rider, this command is called "Search Everywhere".
On my installation of VS 2022 the placeholder text within the search box is "Search (Ctrl+Q)".
Pressing this shortcut in the keyboard mappings yields the Shortcut Window.QuickLaunch
The page you linked to also shows this is the default settings for Window.QuickLaunch.
According to Visual Studio documentation
Use the Ctrl+Q keyboard shortcut to access the search box
Advance Shortcuts:
The search results include tabs for All, Code, Visual Studio. You can save time by using the following keyboard shortcuts for different types of searches:
Ctrl+Q, Ctrl+T for files, types, and members
Ctrl+Q, Ctrl+M for Visual Studio menus, options, components, and templates
Ctrl+Q, Ctrl+E to go to the All tab, for both
Please try with Ctrl+Q it is working fine in visual studio 2022.

How to stop Visual Studio from putting extra newline at the end of a file on save

I'm using Visual Studio 2019, and when I save a file (a cs file for example) VS will put an extra newline at the of the file.
I need to stop this behavior, but what I have searched on the internet so far, was about visual studio code or editors other than Visual Studio.
What is the philosophy of putting an extra newline at the end of file?
According to this link, I need to make Advanced Save Options menu visible, and then click it and change line endings dropdown value from Current Settings to Windows (CR LF).

Visual Studio: Shortcut to close window not working

I changed the shortcut to close a window to Ctrl+W and to close all windows to Ctrl+Shift+W. Close all windows works fine, but Ctrl+W selects the word currently under the cursor but does not close the window.
When I right-click a tab it say Ctrl+W is the shortcut to close it (And also Ctrl+S to save and Ctrl+Shift+W to close all). Why is only the close window shortcut not working?
In Visual Studio (VS 2015 in my case but it's similar down to VS 2010 at least) keyboard shortcuts may have a different meaning depending on the context in which they are executed.
Click Tools / Options / Environment / Keyboard to look up or define shortcuts (you already did that probably). What I called "context" is selected in the combobox labelled "Use new shortcut in:". Most likely you defined the shortcut in "Global" but you want it to work in "Text Editor". In the latter Ctrl+W selects the current word.
Redefine Ctrl+W for "Text Editor" and you should be fine.
I am using Visual Studio 2017 & Visual Studio 2019 and tried the answer from #TobiMcNamobi but it didn't work for me. After few such tries I got it work with below steps.
You should add it as Global shourtcut otherwise it will not work for Designer views.
Add CTRL+W as a Global shortcut for Window.CloseDocumentWindow
Remove the CTRL+W shortcut for Edit.SelectCurrentWord
In Visual Studio 2019 it is Ctrl-F4 by default to CloseDocumentWindow. The action is Window.CloseDocumentWindow. I know this is old but the accepted answer has you change the short-cut key instead. I would rather use the default option.
Tools -> Options -> Environment -> Keyboard
If you're ever unsure go to the path above and you will see the image above then you can click inside the box "Press shortcut key" at the bottom of the form and type the short cut key you're interested in and it will tell you if it is used and what it is currently used for.
You can also reference the docs
https://learn.microsoft.com/en-us/visualstudio/ide/default-keyboard-shortcuts-in-visual-studio?view=vs-2019
2021: For Visual Studio 2019:
See: https://gist.github.com/jpoehls/2030795#gistcomment-2335647
In my case, I had to existing assignments that I had to remove. Thereafter, I could use the hotkey.
In my case, the tabs were not closing because I am using Vim extension. I had to add the following lines to Vim settings:
"vim.handleKeys": {
"<C-w>": false
}
Just press Ctrl + , or Command + , for Mac users, search for Vim and go into Edit in settings.json as the following picture shows:
Screenshot
For Visual Studio 2022, make sure you also remove Ctrl+W from selectCurrentWord command.
In my VS Pro 2019, on Tools / Options / Environment / Keyboard, the first line offers using a premade keyboard mapping scheme, with a drop-down option for VSCode keyborad mapping theme.
I picked it and it seems to have adopted the keyboard shortcuts I was used to from working on VSCode, Ctrl+W included.
For those using linux with VSCode v1.56.2,
File --> Preferences --> Keyboard Shortcuts.
Search for View:Close Editor and as mentioned above, remove any keybinding that has the keybinding you want.

Why does the Visual Studio editor show dots in blank spaces?

I have a strange bug in the Visual Studio text editor.
All my blank spaces are replaced by a "."
public class Person
{
int age;
}
looks like this
public..class..Person..........................
{..................
..int age;...................
}.....................
I reset the settings to default. Didn't work.
I also re-installed VS2008. Still didn't work.
What's the error?
Visual Studio is configured to show whitespace.
Press Ctrl+R, Ctrl+W.
If you are using C# keyboard mappings: (thanks Simeon)
Press Ctrl+E, S.
If you want to use the menu: (thanks angularsen)
Edit > Advanced > View White Space
Looks like you have the view white space option enabled. Go to Edit -> Advanced -> and uncheck "View Whitespace"
In Visual Studio 2012
Go to
Edit -> Advanced -> View White Spaces
Or
Press Ctrl+R, Ctrl+W
~ FOR VISUAL STUDIO 6 ~
use: ctrl+shift+8
to toggle on/off.
(or manualy go to: Edit> Advance > "View Whitespaces")
goodluck!
Works also for Visual Studio 2008, when
Tools/Options/Environment/Keyboard/Mapping Scheme: Visual C++ 6
is selected.
Please press below buttons in combination of
Ctrl + R,W
I had the same problem and resolved by pressing Ctrl + R , Ctrl + W.
In Visual Studio vesrion 1.34.0 View -> Toggle Render Whitespace
Press ctrl + E followed by S key to remove the lines in Visual Studio 10
go to File -> Preferences -> Settings, this will open two panels side by side, the left one is default setting and the right one is user setting, you can add your setting on right panel, for this you can add "editor.renderWhitespace": "all".
In visual studio 2015, goto->view->formatting marks, unselect show
In Visual Studio 2019, this can also be configured in Tools -> Options -> General -> View whitespace

Per-filetype "View whitespace" setting in Visual Studio

Is there a way to enable/disable the "View Whitespace" feature in Visual Studion on a per-filetype basis? I'd like to be able to edit python files with visible whitespace, but not other types.
Unfortunately, there is not a way to do this. The 'View White Space' setting (available from the Edit|Advanced|View White Space' menu option) is stored in the registry, which means the setting is applied to all files and all sessions of Visual Studio.
The next best thing is learn the shortcut key and toggle the feature on and off as necessary. For Visual Studio 2008, the shortcut is Ctrl+E, S.

Resources