Top 13 vs code shortcuts to increase your productivity

written by Idriss Douiri

4 min read

vs code shortcuts blog poster

Visual Studio Code is by far the most used code editor by developers according to stackoverflow survey.

stackoverflow ide 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 line

With Ctrl+Shift+k, you can delete one or more lines.

2. Copy line 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 line 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

In 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 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 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 check if there is 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 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.

outro

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 download the keyboard shortcut reference sheet for (macOS, Windows or Linux).

List of shortcuts

Win/LinuxmacOSAction
Ctrl+Shift+KCmd+Shift+KDelete current line(s)
Shift+Alt+/Shift+Option+/Copy line up/down
Alt+/Option+/Move line up/down
Ctrl+/Cmd+/Toggle line comment
Ctrl+EnterCmd+EnterInsert line below
Ctrl+Shift+EnterCmd+Option+EnterInsert line above
Ctrl+LCmd+LSelect current line
Ctrl+DCmd+DAdd selection to next Find match
Ctrl+Shift+LCmd+Option+LSelect all occurrences
Ctrl+FCmd+FFind and replace
Ctrl+Shift+FCmd+Shift+FGlobal Find and Replace
Ctrl+PCmd+POpen File
Ctrl+WCmd+Wclose tab
Ctrl+BCmd+Btoggle side bar
Ctrl+`Cmd+`Open integrated terminal