Most useful shortcuts for VSCode that everyone should know.
By: Harshul Kansal
Tags: Best Practices, Speed, Vscode, Shortcuts, Save Time

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

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

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

Shift + Alt + .

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

3. Open selected file in file explorer:

Shift + Alt + 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

All unsaved files get saved in the tabs.

5. Selects the breadcrumbs:

Ctrl + Shift + .

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

6. Fold the selected scope:

Ctrl + Shift + [ Folds the selected scope.

Ctrl + Shift + ] Opens the selected scope.

7. Navigate between the tabs:

Ctrl + PageUp Goes to the next tab.

Ctrl + PageDown Goes to the previous tab.

8. Multiply cursors in rows:

Ctrl + Alt + ⬇ || Ctrl + Alt + ⬆

Generates multiple cursors in the same column and different rows.

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

Ctrl + Enter

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

10. Duplicate the line:

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

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

11. Indent the line:

Ctrl + ]

Indent only one single line (or selected lines).

12. Open tab in the sidebar:

Ctrl + \

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

13. Global search and replace:

Ctrl + G || Ctrl + 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

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

Takes cursor to last edit location.

16. Go to file:

Ctrl + P

Type the filename in the popped pallet.

17. Go to the line:

Ctrl + G

Takes cursor to Entered line number.

18. Peek definition:

Alt + F12

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

19. Indent the document:

Ctrl + Alt + F

Indents the whole document.

20. Go to bracket:

Ctrl + Shift + \

Goes to the nearest closing bracket.

21. Trace the cursor trail:

Alt + ⬅

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

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

Free:

Ctrl + K then Ctrl + 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.