DEV Community

Cover image for 5 VS Code Shortcuts To Up Your Productivity
John ✨️
John ✨️

Posted on • Originally published at johna.hashnode.dev

5 VS Code Shortcuts To Up Your Productivity

Working in a moderate-sized to large codebase usually involves having to trace through many source files to see how different components interact with one another, especially when you're new to the project or starting a new ticket that involves code blocks you are not familiar with.

So these shortcuts in VS Code can help you find your way quickly in the codebase faster and more efficiently.

1️⃣ Search for Files: Ctrl + P (Windows/Linux), Command + P (Mac)

This helps you quickly search for and open files in your workspace. It does this by providing a drop-down of suggestions which changes accordingly as you type in the name of the file you're searching.

Ctrl + P Shortcut in VS Code

2️⃣ Find and Replace: Ctrl + F (Windows/Linux), Command + F (Mac)

This allows you to find and replace text in the current file. It is done by an overlying input bar that takes in your entries and matches them simultaneously with corresponding lines of code in the file. Matching lines of text get highlighted and you can also move up or down lines of code that match thanks to the up and down arrows next to the input.

Ctrl + F Shortcut in VS Code

3️⃣ Move Line Up/Down: Alt + Up/Down Arrow (Windows/Linux/Mac)

This one allows you to quickly move a line of code up or down in the file. This happens by having the cursor on the line you intend to move and then you apply the Alt + Up/Down Arrow.

Alt + Up/Down Arrow Shortcut in VS Code

4️⃣ Multi-Cursor Editing: Alt + Click (Windows/Linux/Mac)

Have you ever had to rename multiple instances of an identifier in a file? Well, this shortcut adds multiple cursors to your code, which makes such multi-line changes possible. You can also select instances of a variable or function name (or just about any line of text) by highlighting it and then doing Ctrl + D on Windows/Linux or Shift + Cmd + L on Mac.

Alt + Click Shortcut in VS Code

5️⃣ Switch between Open Files: Ctrl + Tab (Windows/Linux), Command + Tab (Mac)

This allows you to switch between open files in your workspace. It toggles between the current file and the one you visited last. But you could also go to other files with Ctrl + Shift + Tab (Windows/Linux) or Cmd + Shift + Tab (Mac).

Ctrl + Tab Shortcut in VS Code

Wrapping Up

Ctrl + Tab, Ctrl + F and Ctrl + P (on Windows) are the three shortcuts I use most because I often have to search for identifiers and blocks of code among files, followed by Alt + Up/Down. Multi-cursor editing comes once in a blue moon and I also tend to just forget about it.

There are more VS Code shortcuts but I tend to use these because they come in handy and don't need many keystrokes.

Top comments (0)