Wednesday, May 26, 2021

Visual Studio Tips and Shortcuts

The Visual Studio is an advanced IDE which allows many features to develop applications in different languages like Visual Basic, C#, F#, JavaScript, TypeScript and so on. 

A shortcut is written for an action in the menu item side by side. The user can use it. But another possibly is of using the hotkeys. 

A hotkey based shortcut begins with the ALT key. It activates the Menu bar and hotkeys of the menus of the bar. This hints the user to press the next key. For example, we can press ALT+V+P to activate the Solution Explorer. 

The View Menu contains shortcuts to open different windows such as Solution Explorer, Output etc.
Note that the title bar of an active window in the Visual Studio becomes light green/orange. This is shown below. 


Pressing the SHIFT+ESC together closes the active window in the Visual Studio. For example, press CTRL+ALT+O to open/activate the Output window and then press SHIFT+ESC to close it. 

To deactivate a window, we simply press ESC. The deactivated window will appear in violet color.

Advantages of Hotkeys

Sometimes, hotkeys are better alternative than the provided shortcuts. For example, we can activate Solution Explorer window by clicking CTRL+ALT+L. But we can do the same using ALT+ V+P. The advantage of using hotkeys is that the sequence of keys to be pressed comes up sequentially and it is easier to follow than a shortcut which need to be memorized. If the number of keys to be pressed sequentially is large, it may become slightly uncomfortable but in general it is easy to use hotkeys. It is useful when shortcut is not available to do an activity. For example, to close the Solution, no shortcut is available. There is no shortcut for Rebuild or Clean in the Build Menu. We can use ALT+B,B to Build and ALT+B,C to Clean and ALT+B,R to Rebuild the project. Note that first B stands for Build Menu and next letter (B,C,R) is first character of Build, Clean and Rebuild respectively. Obviously it is very easy to remember such commands.

To open a submenu within a menu, arrow direction is shown. We have to press right arrow key to open the submenu.


We can open multiple instance of Visual Studio to work with different projects at the same time. We press CTRL+SHIFT+N to create a new project. Press ESC if you pressed it inadvertently.

The hotkey based shortcuts to do an action:
  1. ALT +F+T To close the Solution (No shortcut given for it in File Menu)
  2. ALT+F+X To close the Visual Studio or ALT+F4
The Edit menu contains a number of Advanced shortcuts to edit the entire document or selection. The selection can be a single line or more than a line. For example, 
  • CTRL+K, CTRL+C To Comment selection
  • CTRL+K, CTRL+U To Uncomment selection
  • CTRL+K, CTRL+D To format entire Document
  • CTRL+K, CTRL+F To format the selection
  • CTRL+K, CTRL+/ To toggle the line comment
  • CTRL+U To Lowercase the selection
  • CTRL+SHIFT+U To Uppercase the selection
  • ALT+ Up Arrow To Move Up the Selection
  • ALT+ Down Arrow To Move Down the Selection 
  • CTRL +D To duplicate the selection
  • CTRL+SHIFT+L To Delete the selection
  • CTRL+E, CTRL+W To wrap the text
More shortcuts can be seen in the Edit Menu as depicted below.

Visual Studio Tips Show Hide Line Numbers in code editor and Word wrap. We can show/hide the line number. 
Tools > Options > It appears in the Text Editor ➪ All Languages ➪ General category.


To apply this for C# only, use the C# node as shown below.




No comments:

Post a Comment

Hot Topics