During coding, we frequently rely on the mouse for navigation, scrolling, and other tasks. However, there's a suite of keyboard shortcuts available that can significantly streamline your workflow, saving time and boosting productivity. Here are some handy tips and tricks for maximizing efficiency while working in the Visual Studio text editor (Windows only).
Text Navigation
Shortcut |
Action |
Page Down |
Scroll down |
Page Up |
Scroll up |
Ctrl + Home |
Jump to the beginning of the file |
Ctrl + End |
Jump to the end of the file |
Text Selection
Shortcut |
Action |
Shift |
Activate selection |
Shift + Ctrl + Right/Left |
Select one word at a time |
Shift + End |
Select from the cursor to the end of the line |
Shift + Home |
Select from the beginning of the line to the cursor |
Deleting Text
Shortcut |
Action |
Backspace |
Delete one character to the left of the cursor |
Ctrl + Backspace |
Delete one word to the left of the cursor |
Del |
Delete one character to the right of the cursor |
Ctrl + Del |
Delete one word to the right of the cursor |
Ctrl + L |
Delete the current line |
Commenting Code
Shortcut |
Action |
Ctrl + K, Ctrl + C |
Mark the selection as a comment |
Ctrl + K, Ctrl + U |
Remove the comment from the selection |
Bookmarking
Shortcut |
Action |
Ctrl + K, Ctrl + K |
Toggle a bookmark |
Ctrl + W, B |
View the Bookmarks window |
Expanding / Collapsing
Shortcut |
Action |
Ctrl + M, Ctrl + M |
Expand / Collapse a code block |
Tabs & Windows
Shortcut |
Action |
Ctrl + Tab |
Cycle through open tabs |
Ctrl + Shift + Tab |
Reverse cycle through open tabs |
Ctrl + F6 |
Go to the next tab |
Ctrl + Shift + F6 |
Go to the previous tab |
Ctrl + F4 |
Close the current tab |
Alt + W + L |
Close all open tabs |
Ctrl + , |
Open the navigate dialog |
Shift + Alt + Enter |
Toggle full-screen mode |
Find & Replace
Shortcut |
Action |
Ctrl + F |
Display the Find dialog |
Ctrl + Shift + F |
Display the Find in Files dialog |
F3 |
Find the next occurrence of the search text |
Shift + F3 |
Find the previous occurrence |
Ctrl + H |
Display the Replace dialog |
Alt + R |
Replace the currently selected occurrence |
Alt + A |
Replace all occurrences of the search text |
Running and Debugging
Ctrl + F5 |
Run the application |
F5 |
Run the application in debug mode |
Shift + F5 |
Stop the debugging session |
F9 |
Insert or remove a breakpoint |
F10 |
Step over a method |
F11 |
Step into a method |
Shift + F11 |
Step out of a method |
Code Snippets (important !)
Here's a table summarizing the Visual Studio shortcuts for code generation.
Shortcut |
Description |
class |
Create a class |
ctor |
Create a constructor |
prop |
Create an auto-implemented property |
prop full |
Create a property with a private field |
equals |
Override the Equals method of the base Object class |
for |
Create a for-loop |
for |
Create a for loop that decrements the loop variable |
for each |
Create a foreach loop |
while |
Create a while loop |
do |
Create a do loop |
try |
Create a try/catch block |
tryf |
Create a try/finally block |
interface |
Create an interface |
Formatting code
Shortcut |
Description |
Tab |
Move the selection one tab stop to the right |
Shift + Tab |
Move the selection one tab stop to the left |
Ctrl + K, Ctrl + F |
Format the code |
Hope this helps and saves you time. Happy Coding!