Here are some VS Code keyboard shortcuts for you, now stop using mouse.

A list of commonly used VS Code keyboard shortcuts that might come in handy.

Madhav Bahl
codeburst

--

Let me tell you the story of Jimmy. Jimmy is a software developer in a big IT company, everyone respects him, he is an amazing man.

One day, his colleague watched him using mouse for everything, and the news spread like forest fire. Once respected Jimmy was now looked down by his fellow programmers, Jimmy felt left out, everyone saw Jimmy like this -

Don’t be like Jimmy

Let me tell you a secret, if you call yourself a programmer, and you are still using your mouse for everything, you are going to be judged a lot ( ͡° ͜ʖ ͡°)

Ok jokes apart, I was kidding, there is no Jimmy, everyone in the industry prefer using keyboard ( ͡ᵔ ͜ʖ ͡ᵔ )

Haha, I got you there, don’t worry, it’s nothing like that, there’s no compulsion of using keyboard over mouse, and no one’s going to judge you even if you use mouse (maybe), but still, it is always recommended to minimize the usage of mouse as much as possible, it saves a lot of time.

So one day jimmy thought of pressing ctrl + alt + del instead of right clicking the taskbar and then left click on task manager. He noticed that it just took a moment to press three keys together rather than dragging the pointer all the way to taskbar and then doing the thing. That day, Jimmy decided that he is going to start using keyboard shortcuts, and I am going to help Jimmy do that, let’s read the complete story of our Jimmy.

Jimmy is happy

Ok Jimmy, let me tell you something before going forward

So Jimmy, I don’t know whether you are a windows user or a mac user, but I don’t want to write this article two times, so I will just assume that you are a windows user, and in case you are a mac user, try to follow the same shortcuts by using command key instead of ctrl key, and most of them should work. And Jimmy if they don’t work, you know what do you have to do, you have to write it down in the comments section.

Let’s get started, Jimmy!

In this blog, Jimmy, I am going to tell you some VS Code keyboard shortcuts which might be helpful to you in your day to day work, and in a few days you will be able to see how easy it is to do things from keyboard, mouse is just “SLOW”. Btw, Jimmy, don’t forget to write it down in the comments section if I forget to add any shortcut which might be essential in your day to day work.

Before we start, I know that you want an index of contents so that you can directly refer to the shortcut you want ( ✧≖ ͜ʖ≖)

  1. Open the terminal
  2. Reload VS Code
  3. Switch between tabs
  4. Open a file (search by file name)
  5. Open a file (search by text)
  6. Open a file in your system
  7. Replace the matching occurrence in file
  8. Replace the matching occurrence in whole project
  9. Move a line up/down
  10. Search in a file/project
  11. Open the command palette
  12. Open/Close Sidebar
  13. Open and use File Explorer
  14. Open the Source control
  15. Open the VS Code extensions Marketplace
  16. Create a new tab group
  17. Switch between tab groups
  18. Move the current tab to left/right tab group
  19. Move to the beginning/end of the file
  20. Add multiple cursors
  21. Add cursor above/below
  22. Select a word
  23. Delete a word
  24. Close the current tab

Alright, so jimmy, let’s get started.

1. Open the terminal

Hey Jimmy, did you know that VS Code comes with an integrated terminal? You really don’t need to go to your project directory and open the terminal, you can directly use the VS Code integrated terminal for various commands that you need in your project.

Keyboard shortcut - ctrl + ` (backtick)

control + backtick

2. Reload VS Code

So Jimmy, did you know, you can reload your editor without actually closing and re-opening it. Here’s how - ctrl + alt + r

Btw, I just remembered something, did you know that you can open dev tools in your vs code?

Have a look (yeah, I’ll be using mouse, just to show you from where you can open)

3. Switch between tabs

Hey Jimmy, I saw you using your mouse to switch between tabs, don’t do that bro, use this little shortcut -

Switch between recent tabs — ctrl + tab

You can also switch between tabs in order using — alt + <number>

For example, alt + 1 alt + 2 alt + 3 and so on…

4. Open a file (search by file name)

Well yes Jimmy, if you directly want to open a file when you know the file name and your project directory is open in vs code, it’s simple,

Keyboard Shortcut — ctrl + p and then start typing your file name.

5. Open a file (search by matching text)

The previous method is rather common, let’s say you don’t remember the file name, but you do remember some symbol in it, you can even use that to search for that file.

Press ctrl + t and start typing.

6. Open a file in your system

Ok, this is the simplest, and I bet you already know this. ctrl + o

7. Replace the matching occurrence in file

Another simple one, just select the word you want to replace and then press ctrl + h

8. Replace the matching occurrence in whole project

Yo Jimmy, from now, don’t go searching for the places where your variable is being used and then replace it. Just press ctrl + shift + h

9. Shift the whole line up/down

Do Jimmy, sometimes we need to shift the whole line up or down. Generally people cut the whole line, and then place the cursor in the above line, and then paste it. You can do this at once by alt + up Arrow and alt + down arrow

10. Search in a file/project

We can search in a file by — ctrl + f
We can search in the whole project by — ctrl + shift + f

11. Open the command palette

You can open the command palette using ctrl + shift + p

12. Open/Close Sidebar

So Jimmy, if you are working on a small screen, you might want some more space to display your code. In such cases, you can hide the side bar by pressing ctrl + b you can again re-open it by pressing the same ( ctrl + b )

13. Open and use File Explorer?

So Jimmy, you want to quickly jump on to some file in your current project directory? Apart from searching for it using the above method, you can even try out the file explorer using ctrl + shift + e

14. Open the Source control

Although I personally prefer using git on terminal/command line, but many people love using the VS Code integrated source control. If you are one of them, you don’t need to manually go to the side bar and click on that button. Use this shortcut —

15. Open the VS Code extensions Marketplace

Yes, you can even open the VS Code marketplace using this simple keyboard shortcut —

16. Create a new tab group

Creating a tab group is troublesome if you do it using mouse. On the contrary, it is very easy if you are using keyboard shortcuts. To create a new tab group, all you need to do is press ctrl + (number of tab groups open) + 1

Seems confusing? Alright, let’s say you initially have 1 tab tab group open, then you’ll have to press ctrl + 2

After that you would be pressing ctrl + 3 for a new tab group, and so on…

These shortcuts remain the same when you want to switch between tab groups. Let’s say you are working on the third tab group, and you need to switch to the first tab group. All you need to do is press ctrl + 1

17. Switch between tab groups

Yeah Jimmy, I know that I have already mentioned this shortcut in the previous section, but still I guess this should have a mention separately as well, as I see many people struggling to switch tab groups.

It’s very simple, ctrl + n
Here, n is the number of tab group you want to switch to, can be 1, 2, 3 and so on…

For first tab group — ctrl + 1
For second tab group — ctrl + 2
For third tab group — ctrl + 3
And so on…

18. Move the current tab to left/right tab group

Now since we are talking about tab groups, you should also know how to shift a particular tab in the left or right tab group.

Shift to right tab group — ctrl + alt + right arrow key
Shift to left tab group — ctrl + alt + left arrow key

19. Move to the beginning/end of the file

Yeah, this might not be used by you very often, but still it might come in handy sometimes. If you directly want to go at the start or the end of the file, use these -

Go to start: ctrl + home
Go to end: ctrl + end

20. Add multiple cursors (alt + click)

Sometimes we have to write the same thing at multiple places, we can do that by using multiple cursors. Just press alt + left mouse click

21. Add cursor above/below

Now that we have talked about adding multiple cursors, we can take this one step further. Let’s say you have to add same thing in adjacent lines, then you can use ctrl + alt + up/down arrow key

22. Select a word

Yeah, I should have placed this in starting, you will find yourself using this shortcut many times, not only in VS Code, but also while typing generally.

Sometimes we need to skip some words and take our cursor to some specific position. In that case we can directly skip 1 word at a time by pressing ctrl + right/left arrow key

Moreover, sometimes we might need to select a few words at once. To do so, we can directly do that by pressing the shift key as well while doing the above step. Shortcut — ctrl + shift + left/right arrow key

Also, if you want to select only a single word, then you can do it even more directly just by pressing ctrl + d

23. Deleting the next/previous word

Similar to what we discussed above, we can also delete words directly. Just press ctrl + backspace/delete

24. Close the current tab

Alright, this is the last one for today, to close the current tab you can directly press ctrl + w

These were some keyboard shortcuts that might be helpful to you in your day to day work. In case you feel that I missed any important shortcut, let me know by writing it in comments.

Also, if you are interested to read about more keyboard shortcuts, have a look at this pdf —

https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf

Btw, did you know that I mentor a huge student community reaching over more than 10000 students, and that too for free. In case you wish to keep hearing from me about my blogs, podcasts, webinars, meetups, and other initiatives, subscribe to my mailing list now ( ͡~ ͜ʖ ͡~)

http://madhavbahl.tech/subscribe/

That’s it, hope you found the post useful!

Feel free to reach out to me anytime if you want to discuss something :D

I would be more than happy if you send your feedback, suggestions or ask queries. Moreover, I love to make new friends and we can be friends, just drop me a mail.

Thanks a lot for reading till end. You can contact me in case if you need any assistance:
Email: theleanprogrammer@gmail.com
Web:
http://madhavbahl.tech/
Github:
https://github.com/MadhavBahlMD
LinkedIn:
https://www.linkedin.com/in/madhavbahl/
Instagram:
https://www.instagram.com/theleanprogrammer/

--

--

✨ Tech, Fitness and Lifestyle - Helping software professionals stay fit and grow in career ✨