DEV Community

Cover image for 20 VS Code Shortcuts to Enhance Your Coding Productivity
Usman Awan
Usman Awan

Posted on

20 VS Code Shortcuts to Enhance Your Coding Productivity

20 Essential VS Code Shortcuts for Professional Developers

Visual Studio Code (VS Code) is a widely popular code editor, known for its powerful features that boost developers’ productivity. Mastering VS Code shortcuts is a key way to enhance your workflow, making coding faster and more efficient. Here’s a breakdown of 20 essential VS Code shortcuts that every professional developer should know. Whether you use macOS, Windows, or Ubuntu, these shortcuts will help you optimize your coding experience.

1. Opening and Closing Sidebar

You can toggle the sidebar (explorer, search, etc.) on and off without clicking manually.

  • Mac: Command + B
  • Windows/Linux: Ctrl + B

2. Select Word

Select the word where your cursor is placed. Press the shortcut repeatedly to select multiple occurrences of the word.

  • Mac: Command + D
  • Windows/Linux: Ctrl + D

3. Split Editor

The split editor feature allows you to open side-by-side editors, useful for comparing files or referencing one while working on another.

  • Mac: Command + \ or Command + 2/3/4
  • Windows/Linux: Shift + Alt + \ or Shift + Alt + 2/3/4

4. Code Folding

When dealing with long files, folding and unfolding code blocks can make navigation easier.

  • Fold:

  • Mac: Command + Option + [

  • Windows/Linux: Ctrl + Shift + [

  • Unfold:

  • Mac: Command + Option + ]

  • Windows/Linux: Ctrl + Shift + ]

5. Copy Line Up/Down

Copy the current line and paste it directly above or below without manually copying and pasting.

  • Mac: Shift + Option + Up/Down
  • Windows/Linux: Shift + Alt + Up/Down

6. Code Formatting

Automatically format your code according to your editor's settings.

  • Mac: Shift + Option + F
  • Windows/Linux: Shift + Alt + F

7. Trim Trailing Whitespaces

Remove trailing whitespaces when you save a file. You can enable this feature in your settings:

Go to Preferences > Settings and add "files.trimTrailingWhitespace": true.

8. Join Lines

Join multiple lines of code into one.

  • Mac: Ctrl + J
  • Windows/Linux: Open the Keyboard Shortcuts menu and bind editor.action.joinLines to your desired key combination.

9. Quick File Open

Quickly open any file in your workspace by searching for its name.

  • Mac: Command + P
  • Windows/Linux: Ctrl + P

10. Command Palette

The command palette allows access to various VS Code commands and features based on the current context.

  • Mac: Command + Shift + P
  • Windows/Linux: Ctrl + Shift + P

11. Toggle Terminal

You can quickly open and close the integrated terminal with this shortcut.

  • Mac: Command + Backtick ( \ )`
  • Windows/Linux: Ctrl + Backtick ( \ )`

12. Switch Tabs

Switch between open editor tabs without using your mouse.

  • Mac: Command + 1/2/3
  • Windows/Linux: Ctrl + 1/2/3

13. Select Current Line

Quickly select the entire line where the cursor is placed.

  • Mac: Command + L
  • Windows/Linux: Ctrl + L

14. Delete Line

Remove the current line without selecting or cutting it.

  • Mac: Command + Shift + K
  • Windows/Linux: Ctrl + Shift + K

15. Move Line Up/Down

Move the current line up or down without using cut and paste.

  • Mac: Option + Up/Down
  • Windows/Linux: Alt + Up/Down

16. Find Word/Phrase

Find specific words or phrases in your code. You can search within the current file or across the entire project.

- Find in File:

  • Mac: Command + F
  • Windows/Linux: Ctrl + F

- Find in Project:

  • Mac: Command + Shift + F
  • Windows/Linux: Ctrl + Shift + F

17. Peek Definition

Peek at the definition of a function or variable without opening the file containing its declaration.

  • Mac: Option + F12
  • Windows/Linux: Alt + F12

18. Rename Symbol

Rename a symbol across all occurrences in the file.

  • Mac/Windows/Linux: F2

19. Multi-Cursor Selection

Place multiple cursors in your code to make simultaneous edits.

  • Mac: Option + Click
  • Windows/Linux: Alt + Click

20. Duplicate Line

Duplicate the current line or selected lines.

  • Mac: Command + Shift + D
  • Windows/Linux: Ctrl + Shift + D

Conclusion

VS Code is an incredibly powerful code editor, and learning its shortcuts can greatly improve your productivity. These 20 essential shortcuts will help you code faster and more efficiently. Incorporating them into your daily workflow will save time and reduce repetitive tasks, allowing you to focus more on coding.

Mastering these shortcuts is a small investment that yields big returns in terms of speed and efficiency. Happy coding!

Top comments (0)