DEV Community

Cover image for 23 lesser known VS Code Shortcuts as GIF
Andreas
Andreas

Posted on • Updated on

23 lesser known VS Code Shortcuts as GIF

Despite many shortcuts I'm using frequently in VS Code, the following ones can come in very handy but I'm often forgetting they even exist. I made some GIFs for visualization to better remember them. Maybe there are some shortcuts you didn't remember either but are useful for you.

Every command in VS Code can also be executed via command prompt with CTRL+SHIFT+P and a search query. But knowing the direct shortcut might be faster.

I use VS Code on Windows in the GIFs, but I also provide a table showing the shortcuts for both Windows and Mac for each command.

1. CTRL+, = Open user settings

Windows Mac
CTRL+, +,

Open user settings in VS Code

Once in a while I need to adjust my user preferences, this is how you open them directly.

2. CTRL+K   CTRL+S = Show shortcuts

Windows Mac
CTRL+K   CTRL+S +K   +S

Show shortcuts in VS Code

This is the complete list of shortcuts in VS Code. There is also a Windows Cheat-Sheet [PDF] and MacOS Cheat-Sheet [PDF] available to download.

3. CTRL+R = Switch workspace

Windows Mac
CTRL+R +R

Switch workspace in VS Code

This opens a list of your recent workspaces and is a super fast way to switch to another folder or project. Note that this will kill you current terminal session, if you had a terminal open in your VS Code workspace.

4. ALT+Z = Toggle word wrap

Windows Mac
ALT+Z +Z

Toggle word wrap in VS Code

A handy little helper when you quickly want to see complete lines without scrolling horizontally.

5. CTRL+G = Go to line

Windows Mac
CTRL+G ^+G

Go to line in VS Code

This is the shortcut for typing CTRL+P   :.

6. CTRL+P = Go to file

Windows Mac
CTRL+P +P

Go to file in VS Code

The fastest way to switch files (especially when they are not already open) without using the mouse.

7. F8 = Go to next error or warning

Windows Mac
F8 F8

Go to next error or warning in VS Code

This is debugging with a single key. You can also go to previous errors or warnings using SHIFT+F8.

8. CTRL+TAB = Switch tabs

Windows Mac
CTRL+TAB ^+TAB

Switch tabs in VS Code

The fastest way to switch already open files without using the mouse.

9. SHIFT+ALT+I = Insert cursor at end of each line selected

Windows Mac
SHIFT+ALT+I ++I

Insert cursor at end of each line selected in VS Code

This is useful for a quick creation of multiple cursors in the selected area.

10. CTRL+L = Select current line

Windows Mac
CTRL+L +L

Select current line in VS Code

Use this i.e. to search for identical lines in combination with the next shortcut.

11. CTRL+SHIFT+L = Select all occurrences of current selection

Windows Mac
CTRL+SHIFT+L ++L

Select all occurrences of current selection in VS Code

This shortcut really saves time because you don't have to CTRL+D through a whole file.

12. CTRL+F2 = Select all occurrences of current word

Windows Mac
CTRL+F2 +F2

Select all occurrences of current word in VS Code

With this you don't even have to select something anymore. Just place the cursor on the word you want to select all occurrences of.

13. CTRL+SHIFT+SPACE = Trigger parameter hints

Windows Mac
CTRL+SHIFT+SPACE ++SPACE

Trigger parameter hints in VS Code

In case you don't remember parameter order and don't want to interrupt your flow by looking into the docs.

14. SHIFT+ALT+F = Format document

Windows Mac
SHIFT+ALT+F ++F

Format document in VS Code

Because nobody wants to format a whole file manually.

15. CTRL+K   CTRL+F = Format selection

Windows Mac
CTRL+K   CTRL+F +K   +F

Format selection in VS Code

In case you want to format only some parts of a file.

16. F12 = Go to Definition

Windows Mac
F12 F12

Go to Definition in VS Code

The quick way to jump to the definition of a variable or function.

17. ALT+F12 = Peek Definition

Windows Mac
ALT+F12 +F12

Peek Definition in VS Code

This just shows the corresponding definition of a variable or function without moving the cursor.

18. F2 = Rename Symbol

Windows Mac
F2 F2

Rename Symbol in VS Code

An indispensible shortcut for refactoring code.

19. CTRL+K   CTRL+X = Trim trailing whitespace

Windows Mac
CTRL+K   CTRL+X +K   +X

Trim trailing whitespace in VS Code

This is especially useful for multi-line selections.

20. CTRL+K   R = Reveal active file in Explorer

Windows Mac
CTRL+K   R +K   R

Reveal active file in Explorer in VS Code

In case you want to perform some actions out of your systems file manager instead of VS Code.

21. CTRL+SHIFT+H = Replace in files

Windows Mac
CTRL+SHIFT+H ++H

Replace in files in VS Code

If only one file at a time isn't enough for you.

22. CTRL+K   V = Open Markdown preview to the side

Windows Mac
CTRL+K   V +K   V

Open Markdown preview to the side in VS Code

This way you don't have to switch to the mouse to open a preview.

23. CTRL+K   Z = Enter Zen Mode

Windows Mac
CTRL+K   Z +K   Z

Enter and exit Zen Mode in VS Code

Instantly coding distraction free. To exit Zen mode, hit ESC ESC.

 

So that's it for now. I maintain a repository on GitHub, where I collect commands I tend to forget - check it out if you want:

GitHub logo devmount / CheatSheets

A curated list of everything I look up more than twice

Happy Coding!


Edited: 7th January 2020 (add MacOS shortcuts)
Published: 7th January 2020
Cover Image: https://codepen.io/devmount/full/ExaQjdm

Latest comments (74)

Collapse
 
prscllag profile image
Priscilla

This was super helpful, thank you! I enjoyed your use of gifs to show the shortcuts in action 😃 bookmarking this for later.

Collapse
 
devmount profile image
Andreas

Awesome 👍🏻 Happy to oblige!

Collapse
 
ironcladdev profile image
Conner Ow

How did you make those
GIF images?

Collapse
 
devmount profile image
Andreas

See this answer:

I'm using ScreenToGif. It's a really useful open source tool to quickly create screencasts. The shortcuts can to be inserted in editing mode.

Collapse
 
oananbeh profile image
Obieda Ananbeh

Thank you!
This is awesome

Collapse
 
devmount profile image
Andreas

I'm glad you like it 😊

Collapse
 
aardaipek profile image
Arda İpek

Thanks a lot Andreas 👍

Collapse
 
devmount profile image
Andreas

My pleasure 😊

Collapse
 
randomrambler profile image
Random Rambler

Thank you. You inspired me: dwim.nl/2020-01-16-VSCode%20shortc...

I was wondering: Do you (or anyone else) know of a VSCode extension that advices on shortcuts for actions you perform often?

Collapse
 
devmount profile image
Andreas

Cool! 👏🏻 I'm glad it's useful for you!

I don't know an extension, but if you perform an action with the command prompt CTRL+SHIFT+P you can directly see the defined shortcuts on the right:

command prompt shortcuts

Collapse
 
sairamnagothu profile image
SairamNagothu

Great job..

Collapse
 
devmount profile image
Andreas

Thank you 😊

Collapse
 
herobank110 profile image
David Kanekanian

Actually, the fastest way to switch tabs without using the mouse is using Alt + {n} where n is the tab index.

Collapse
 
devmount profile image
Andreas

Agreed! Thank you for this addition!

Collapse
 
klukiyan profile image
Kiril Lukiyan

This is a collection of good and useful shortcuts for everybody. Though they are not lesser known. Using 95% of them all the time since switching to vscode

Collapse
 
devmount profile image
Andreas

Thank you for your feedback! So you're a real VS Code pro user! Which command didn't you already know (the 5%)?

Collapse
 
klukiyan profile image
Kiril Lukiyan • Edited

3)CTRL+R (such a good one, I somehow didn't know or think about it before)
19)CTRL+K CTRL+X

Thread Thread
 
devmount profile image
Andreas

Well so I'm glad, that there were at least 2 shortcuts that were helpful for you too 😅

Collapse
 
shmink profile image
Tom Nicklin

Select some characters, a var name or whatever. ctrl+D is my favourite, although not the quickest way, to select the next occurrence of what you currently have selected. Habits I guess.

Collapse
 
randompch profile image
randompch

Useful article ! Didn't even know there was a Zen Mode 🤷‍♂️

Collapse
 
devmount profile image
Andreas

I'm glad it was helpful 😊

Collapse
 
jonmaim profile image
Jon Maim

Zen mode 🙌

Collapse
 
devmount profile image
Andreas

💪🏻👌🏻

Collapse
 
10xgeek profile image
Henry

What software or tool did you use to display those keyboard shortcuts on your screen as you typed them?

Collapse
 
devmount profile image
Andreas

I'm using ScreenToGif. It's a really useful open source tool to quickly create screencasts. The shortcuts can to be inserted in editing mode.

Collapse
 
10xgeek profile image
Henry

Thank you so much!!

Thread Thread
 
devmount profile image
Andreas

You're welcome 😊

Collapse
 
russ profile image
Russ

Great read, thank you for sharing! Now I just need to practice some of them to help remember them.

Collapse
 
devmount profile image
Andreas

You're welcome! So do I 😅

Collapse
 
russ profile image
Russ

After I read the article I immediately needed to use one of them and forgot the shortcut but remembered it's possible 😬

Thread Thread
 
devmount profile image
Andreas

😂 Well, do this a couple more times and you won't forget anymore 😅

Collapse
 
ndkhoa1011 profile image
Nguyen Duy Khoa

Thanks a lot

Collapse
 
devmount profile image
Andreas

You're welcome ☺️

Collapse
 
whatthehanan profile image
Hanan Hamza

for the "go-to-line" you can also do ctrl+p and then :{line_number}

Collapse
 
devmount profile image
Andreas

Which is why I wrote at the end of point 5:

This is the shortcut for typing CTRL+P :.

👍🏻