Top 13 vs code shortcuts to increase your productivity
written by Idriss Douiri
4 min read
Visual Studio Code is by far the most used code editor by developers according to a Stackoverflow survey.
However, to unlock its full power, you have to use the keyboard shortcuts. In this article, I want to share with you the shortcuts I use the most that I think everyone should try.
1. Delete Current lines
With Ctrl+Shift+k, you can delete one or more lines.
2. Copy lines Up/Down
If you want to copy some line and past it near, you can use Shift+Alt+↑/↓ to copy lines up or down.
3. move lines Up/Down
Moving lines up and down can involve a lot of copying and pasting, but using the shortcut Alt+↑/↓ makes it easy to do.
4. Comment Line
Many times we comment and uncomment parts of the code for testing purposes, remembering the syntax of comments for each language might not be that hard, but writing each character to comment and deleting them again to uncomment is pretty annoying. Use the shortcut Ctrl+/ to toggle the comment of a block of selection and let vs code decide the right syntax for your language.
5. Insert Line
Sometimes you stack in the middle of a line, wishing to return to a new line. Instead of jumping to the end and pressing Enter, you can use Ctrl+Enter to return to the next line, or Ctrl+Shift+Enter to return to the line before.
6. Select the Current line
You might want to select the entire line for various reasons, and using your mouse is not the only way of doing it; instead, use Ctrl+l.
7. Select the next Occurrence
Sometimes you have the same word in more than one place in the same file, and updating every single one separately will take some time. Instead, use Ctrl+d to select one occurrence of the selected characters, and press it multiple times to select more than one.
8. Select all Occurrences
The previous shortcut is great when you want to select a few occurrences, but if you have a large file with a lot of words that you want to change at once, pressing Ctrl+d is not the best in this case.
Ctrl+Shift+l is the one you need to select all occurrences in the file at once.
9. Find and Replace
This can help if you want to search for some text in your files and replace it if you want.
Searching:
- Press Ctrl+F to open the “Find” panel.
- Enter the text you want to find in the search field.
- You can toggle case-sensitive/regex/whole word using Alt+C/R/W
Replacing:
- Click the angle bracket icon next to the search field, or press Ctrl+H, to open the “Replace” panel.
- Enter the text you want to find in the “Find” field.
- Enter the replacement text in the “Replace” field.
- Choose to replace individual occurrences or all instances at once.
Global Finding and Replace:
Similarly, you can use Ctrl+Shift+F to search and replace text across all files in our project. This is helpful for making global changes.
10. Open File
Having a lot of files can make navigating harder, which is why you should use the quick open panel by pressing Ctrl+p to quickly search files by name and optionally append :
to go to line or @ to go to symbol.
11. Close the Current Tab
I always end up opening many files at once, and that makes finding the file you are currently working on so hard. To get around this problem, hit Ctrl+w/F4 to close the current tab and use the previous shortcut to open files as needed.
12. Toggle Sidebar
The sidebar can be very helpful, but it takes some space, and once you start coding you want to use all the available space, use Ctrl+b to quickly toggle the sidebar.
13. Toggle Terminal
We use the terminal almost in every project, and moving your mouse to open and close it is annoying. Use the shortcut Ctrl+`(backtick) to toggle your terminal.
Conclusion
The shortcuts covered in this article provide a solid foundation for basic and repetitive tasks, you can get and customize all the keybinding by pressing Ctrl+K Ctrl+S or downloading the keyboard shortcut reference sheet for (macOS, Windows, or Linux).
List of shortcuts
Win/Linux | macOS | Action |
---|---|---|
Ctrl+Shift+K | Cmd+Shift+K | Delete current line(s) |
Shift+Alt+↑/↓ | Shift+Option+↑/↓ | Copy line up/down |
Alt+↑/↓ | Option+↑/↓ | Move line up/down |
Ctrl+/ | Cmd+/ | Toggle line comment |
Ctrl+Enter | Cmd+Enter | Insert line below |
Ctrl+Shift+Enter | Cmd+Option+Enter | Insert line above |
Ctrl+L | Cmd+L | Select current line |
Ctrl+D | Cmd+D | Add selection to next Find match |
Ctrl+Shift+L | Cmd+Option+L | Select all occurrences |
Ctrl+F | Cmd+F | Find and replace |
Ctrl+Shift+F | Cmd+Shift+F | Global Find and Replace |
Ctrl+P | Cmd+P | Open File |
Ctrl+W | Cmd+W | close tab |
Ctrl+B | Cmd+B | toggle side bar |
Ctrl+` | Cmd+` | Open integrated terminal |