
In this article, I am going to share with you a lot of tricks and shortcut keys in Visual Studio so you can write code faster. I'll show you how to use your keyboard properly if you want to write code fast and increase your productivity.
Text
- Ctrl+Right/Left to move the cursor one word at a time
- Shift+Ctrl+Right/Left to select one word at a time
- Ctrl+Bakcspace to delete one word to the left of the cursor
- Ctrl+Delete to delete one word to the right of the cursor
- Ctrl+L to delete current line
- Ctrl+X to cut the current line
- Ctrl+C to copy the current line
- Ctrl+U to lower the next letter or the selected word
- Ctrl+Shit+U to upper the next letter or the selected word
Commenting
- Ctrl+K Ctrl+C to mark the selection as a comment
- Ctrl+K Ctrl+U to remove mark the comment
Bookmarks
- Ctrl+K Ctrl+K to toggle a bookmark
- Ctrl+K Ctrl+W to view the bookmarks window
Expanding/Collapsing
- Ctrl+M Ctrl+L to expand or collapse all code blocks
- Ctrl+M Ctrl+M to expand or collapse the current region
- Ctrl+M Ctrl+O to collapse to definitions
Tabs & Windows
- Ctrl+Tab to cycle through the open tabs
- Ctrl+Shift+Tab to reverse cycle
- Ctrl+F6 to go the next tab
- Ctrl+Shift+F6 to go the previous tab
- Ctrl+F4 to close the current tab
- Alt+W+L to close all the open tabs
- Ctrl+, to open the navigate dialog
- Shift+Alt+Enter to toggle the full screen view
Find & Replace
- Ctrl+F to display the Find dialog
- Ctrl+Shift+F to display the Find in Files dialog
- F3 to find the next occurence of the search text
- Shift+F3 to find the previous occurence of the search text
- Ctrl+H to display the Replace dialog
- Alt+R to replace the currently selected occurence
- Alt+A to replace all occurences of the search text
- Ctrl+R Ctrl+R to rename variable/class/method/...
Running & Debugging
- Ctrl+F5 to run the application
- F5 to run the application in the debug mode
- F9 to insert or remove a breakpoint
- F10 to step over a method
- F11 to step into a method
- Shift+F11 to step out of a method
- Shift+F5 to stop the debugging session
Compiling
- Ctrl+Shift+B to build the application without running it
- Ctrl+* E to display error window
- F8 to cycle through the errors
Code snippets
- interface to create an interface
- class to create a class
- propfull to create an a property with private field
- equals to override the equals method of the object class
- for to create a for loop
- forr to create a for loop that decrements the loop variable
- foreach to create a foreach loop
- while to create a while loop
- do to create a do loop
- try to create a try/catch block
- tryf to create a try/finally block
- Ctrl+K Ctrl+X to display available snippets
Formatting code
- Ctrl+K Ctrl+F/Ctrl+D to format the code
Using the shortcut keys in Visual Studio
In below video, you can see how the tips and shortcut keys prensented above can be used in Visual Studio.