Most useful shortcuts for VSCode that everyone should know.

Harshul Kansal
4 min readJun 2, 2021

There are a countless number of shortcuts, I am only writing the ones that I use in my daily life and could benefit developers and save a lot of time.

Prerequisites:

  • VS Code

Getting Started:

1. Global Search:

Ctrl + Shift + F / cmd + shift + F

Allows you to search in all the files (nested as well) starting from the "./” root directory.

2. Auto fix lint error: (cursor/blinking insertion point should be on the code to be fixed)

Shift + Alt + . / option + cmd + .

Fixes the lint error (that is auto-fixable by the linter).

3. Open the selected file in file explorer:

Shift + Alt + R / option + cmd + R

Opens up the file in the explorer. (File should be focused on in the sidebar)

4. Save all unsaved files open in the tabs:

(Ctrl + K) then S / (cmd + K) then S

All unsaved files get saved in the tabs.

5. Compare the active unsaved file with the saved version of the file:

(Ctrl + K) then D / (cmd + K) then D

5. Selects the breadcrumbs:

Ctrl + Shift + . / cmd + Shift + .

Select the breadcrumbs on the top and allows them to navigate easily.

6. Fold the selected scope:

Ctrl + Shift + [ / cmd + option + [Folds the selected scope.

Ctrl + Shift + ] / cmd + option + ]Opens the selected scope.

7. Navigate between the tabs:

Ctrl + PageUp / cmd + option + ➡Goes to the next tab.

Ctrl + PageDown / cmd + option + ⬅Goes to the previous tab.

8. Multiply cursors in rows:

Ctrl + Alt + ⬇ / cmd + option + ⬇

Ctrl + Alt + ⬆ / cmd + option + ⬆

Generates multiple cursors in the same column and different rows.

9. Insert blank line: (Cursor could be anywhere in the line)

Ctrl + Enter / cmd + return

Inserts a new line below the line where your cursor is.

10. Duplicate the line:

Ctrl + Shift + ⬇ ||Ctrl + Shift + ⬆

option + shift + ⬇ ||option + shift + ⬆

Creates the duplicate line below/above the line where the cursor is.

11. Indent the line:

Ctrl + ] / cmd + ]

Indent only one single line (or selected lines).

12. Open the tab in the sidebar:

Ctrl + \ / cmd + \

The tab that you want to open should be open and focused.

13. Global search and replace:

Ctrl + H / cmd + shift + H

Searches the keyword in the whole project folder and replaces it with the desired keyword/expression.

14. Compare the current file with the clipboard data:

(Ctrl + K) then C / (cmd + K) then C

Searches the keyword in the whole project folder and replaces it with the desired keyword/expression.

15. Last edit location:

Ctrl + K then Ctrl + Q / cmd + K then cmd + Q

Takes cursor to last edit location.

16. Go to file:

Ctrl + P / cmd + P

Type the filename in the popped pallet.

17. Go to the line:

Ctrl + G / control + G

Takes cursor to Entered line number.

18. Peek definition:

Alt + F12 / option + F12

The cursor should be on the word you want to check the definition of.

19. Indent the document:

Ctrl + Alt + F / cmd + shift + F

Indents the whole document.

20. Go to bracket:

Ctrl + Shift + \ / cmd + shift + \

Goes to the closing bracket of the scope the cursor is in, if on the closing bracket already then jumps to the opening bracket.

21. Trace the cursor trail:

Alt + ⬅ / control + -

Traces the cursor last visited coordinates (even in between the files).

21. Go to the next occurrence of the highlighted word/symbol/expression:

Ctrl + D / cmd + D

Traverses one by one and selects the succeeding similar words or expressions.

Free:

Ctrl + K then Ctrl + S / cmd + K then cmd + S

Opens the keyboard shortcuts guide and allows you to edit them and set your own hotkey combination as per your convenience.

You can add various key combinations including the following:

  • Changing selected text to uppercase/lowercase.
  • Changing the default terminal.
  • Converting the tab indentation.
  • Duplicate the selection
  • Update the tag, etc.

Do let us know any useful key combinations that we can use, and share the article with your friends and colleagues.

--

--

Harshul Kansal

Self motivated Javascript developer, working towards achieving the best coding style possible.