Stefi Rosca

🚣 10 Must-know VS Code shortcuts

Moving from keyboard to mouse to perform some action can sometimes be annoying. VS Code has some really nice keyboard shortcuts to help keep me in flow when working with code. In this article, we’ll explore 10 must-know VS Code shortcuts that I use on a day to day basis. These shortcuts are not only time-saving but also make you feel like a coding wizard 🧙‍♀️. Let’s dive in!

Disclaimer: Please note that the keyboard shortcuts mentioned are for a MacBook keyboard. Keep this in mind and adapt them to your specific setup as needed.

1. Quick File Navigation with Command ⌘ + P

Even if you are not working in a project with many files this shortcut will come in handy.
Command ⌘ + P will open the search bar at the top, where you can start typing the name of the file you want to open.

This shortcut allows you to quickly locate and open files without the need to manually navigate through folders, saving you valuable time and ensuring you stay focused on your code.

2. Easily Copy/Cut and Paste Entire Line/Block

I didn’t know that I could copy an entire line in VS Code without having to select the whole line. You can simply do Command ⌘ + C or Command ⌘ + X on the line your cursor is on and it will copy/cut the whole line. Cool, right?

demo copy/cut and paste

3. Move Code Up and Down / Move Lines Up/Down

Sometimes you just need to take a code block and move it somewhere else either up or down from where it is to do this you have to:

Select the code you want to move and press Option ⌥ + arrow up/down to move the selected code

If you want to move just one line you can do this without selecting the whole line.

demo move code

4. Toggle Side Panel and Integrated Terminal

Sometimes all I want, especially when I am working on my 14” laptop screen, is to be able to focus on the file with the code without seeing the sidebar or in-build terminal.

Command ⌘ + B will show or hide side bar

Command ⌘ + J will show or hide the in-build terminal

Demo Toggle Side Panel and Toggle Integrated Terminal

I should mention that I keep my side panel on the right side as all code is left to right and I prefer having more space on the left rather than on the right which is the end of the file.

5. Multi-Cursor Editing

There are times you might want to edit code on multiple lines and to do this you have two options:

  • Option ⌥ + Click to get multiple cursors where you click and what you type or delete will happen on all the lines where you see the cursors
  • select a word and then press Command ⌘ + D as many times as you need. This adds a cursor on the the same word (if it exists) selected which every press of Cmd + D and will allow you to change that specific word in all places at the same time. Pretty neat!

Multi-Cursor Editing

6. Navigate a Line of Code Word by Word or from Start to End

Holding Option ⌥ + arrow left/right will make the cursor go through a line word by word, this works also in the terminal. If you press Command ⌘ + arrow left/right you will navigate to the start or end of the line. Command ⌘ + arrow up/down takes you to the beginning/end of file.

Demo Navigate a line of code word by word or start / end

7. Search in All Files with Command ⌘ + Shift ⇧ + F

This is one of my favorites. Sometimes you want to quickly search for a function across the whole project. With Command ⌘ + F you can search the file you are in but if you press Command ⌘ + Shift ⇧ + F you can search in all files of the project.

8. Go to a Specific Line of Code in the File

To go to a specific line in your file press Control + G and then enter the line number. That’s it! Comes in handy especially when pair programming and your partner asks you to change something on a specific line.

9. Close Current File When You No Longer Need It

Command ⌘ + W

10. Navigate Through Your Open Tabs

Control + Tab

Bonus: Copy the line you are on just below

Put the cursor on the line you would like to copy below and press Option ⌥ + SHIFT + arrow down. I haven’t used this one too much so far.

Demo Copy the line you are on just below

It’s not easy to remember all these shortcuts at once. I recommend having a cheat sheet and starting incorporating these slowly, building muscle memory over time.

Happy coding 🚀

Read More:


👩‍💻 Frontend Developer, 🌍 traveler and⛷️ Skier

Recurse Center Alumn

Stefi Rosca © 2024