
As a note, all screenshots are taken with Visual Studio 2017. I’m going to stick to defaults, but later in this post, I’ll show you how to change those. How to get to edit Visual Studio Shortcuts: Click on Tools > Options Under Environment, go to Keyboard. The highlighted section Show commands containing: corresponds to the VS Mapping column in the table that you will see next. If you press shortcut keys, you can assign. And to round it out, the mapping for uncommenting is Ctrl+K, Ctrl+U. Now, Visual Studio knows how to comment in several languages. It can comment in HTML, JavaScript, SQL, C#, CSS-you name it! #Highlight line in visual studio 2017 shortcut how to# The comment shortcut will also lay down comments on a single line or multiple lines. Ctrl+W Text Editor Edit.SelectCurrentWord. Delete Line (without copying it) Ctrl+Shift+L Paste from Clipboard Ring (Paste from buffer of previously copied items) Ctrl+Shift+V Move Code Up / Down Alt+Up arrow / Alt+Down arrow Format Document Ctrl+K, Ctrl+D Format Selection Ctrl+K, Ctrl+F Surround with ( if/try/foreach) Ctrl+K, Ctrl+S Remove and Sort Usings Ctrl+R, Ctrl+G Rename Ctrl+R. That all depends on what you’ve selected with your cursor. #Highlight line in visual studio 2017 shortcut windows#Įsc Text Editor, Report Designer, Settings Designer, Windows Forms Designer, Managed Resources Editor Edit.SelectionCancel. If you’ve got the cursor on a line with no highlighting, it’ll just comment the line from the start of your code. Ctrl+W // close all the documents which are opened if it does not work, add own shortcut. It doesn’t, however, leave a space between the comment characters and your code this has been known to upset JS linters that like to see that space by default.

Non-Keyboard Visual Studio Comment Shortcuts I’ll admit, it’s a bit easier on the eyes.

What if you want to comment multiple lines but leave some space before the code? Normally, Ctrl+K, Ctrl+C will leave the comments in a nice column like in the following example: public class Class1īut notice a few not-so-nice trends in that sample? For one thing, there’s the “missing” comment line with no // and the comment characters are right up against the code. Here, I’m commenting code, so it’s not that much of a problem. I would eventually either delete that code or remove the comments. But what if it’s a really useful comment? #Highlight line in visual studio 2017 shortcut code# Perhaps you’ve left an important note to your colleagues or future self explaining some odd block of code. #Highlight line in visual studio 2017 shortcut windows#.#Highlight line in visual studio 2017 shortcut code#.#Highlight line in visual studio 2017 shortcut how to#.
