DEV Community

Cover image for 10 useful VS Code shortcuts you should know  ()

10 useful VS Code shortcuts you should know ()

Mariana Simon
On a mission to make online learning less boring. Coding live on
Originally published at Updated on ・3 min read

This is a curated list of the shortcuts you should learn as soon as possible. I really wish I knew them when I started coding. It would have saved me hours of manual typing.

Default shortcuts for Linux. Mac and Windows shortcuts are displayed below if different.

1. Ctrl+P : Displays the search bar to search for files

(Mac: Cmd + P)
You will navigate between files all the time. You can type the file name and open it by pressing enter.
search bar

2. Ctrl + Shift + P: Displays the command pallete

(Mac: Cmd + Shift + P)
Displays the command pallete where you can search for an action.
command palete

3. Crtl + B : Toggle the sidebar

(Mac: Cmd + B)
Show or hide the side bar where you can navigate through the explorer.
toggle sidebar

4. Ctrl+Shift+E : Move to Explorer window

(Mac: Cmd + Shift + E)
Move to Explorer window where you have your file tree and can navigate using the arrow keys.
move to explorer

5. Ctrl + Shift + M : Quickly shows errors and warnings

(Mac: Cmd + Shift + M)
Everybody likes bug-free code. This command shows the problems panel where you can see identified errors and warnings.

6. Ctrl + Shift + L: Multi cursor selection

(Mac: Cmd + Shift + L)
Add additional cursors to edit all occurrences of the current selection. Usually less error-prone than doing search and replace all.

7. Ctrl + D : One by one selection

(Mac: Cmd+D)
Similar to the previous one, but use Ctrl + D if you want to add the occurrences of the current selection one by one. Each time you press the key combination it adds a new occurrence to the selection.

8. Ctrl+/ : Toggle line comment

(Mac: Cmd+/)
Toggle between commented and uncommented line behavior.
toggle comment

9. Ctrl + Shift + I: Formats the entire file

(Mac: Shift + Option + F, Windows: Windows Shift + Alt + F)
Formats the entire active file or prompts you to install a Formatter extension. I use Prettier extension to format JS code

10. Alt + Up or Alt + Down: Move line

(Mac: Opt+Down or Opt+Up)
Pretty straightforward. Move line up and down.

Bonus: Wrap with Abbreviation.

Helps you add that missing div tag to an HTML block for example. It is not enabled by default, you need to do it in keyboard shortcuts preferences. Use shortcut 2 listed here (yeah \0/) -> type Preferences:Open Keyboard Shortcuts -> search for Emmet: Wrap with Abbreviation -> choose a key to bind it. I use Alt + M.

Honarable mention:

Ctrl + Space : Show Suggestions
Shows suggestions to quickly fill properties and other stuff.


About me, let's connect! 👋👩‍💻

I'm an avid learner and I love sharing what I know. I teach coding live for free 👉 here and I share coding tips on my Twitter . If you want to, come visit and say hi in the chat 😁

Discussion (49)

equiman profile image
Camilo Martinez • Edited

Excellent recommendations! I would like to add this information:

  • ctrl+i also does the same as ctrl+space it was introduced recently.
  • When using ctrl+d and select more elements than expected, you can undo selections with ctrl+u
who8mypnuts profile image

Thanks! I always wondered about undoing selections when I got too much.

mostafiz93 profile image
Mostafiz Rahman

This is also useful:

cmd + j to toggle Terminal/Output/Debug Console view

simonpaix profile image
Mariana Simon Author

Nice addition. Thanks, Mostafiz!

josef37 profile image
Josef Wittmann • Edited

Fold that stuff! 😄

Have a look at the folding/unfolding shortcuts (I can't post them here, because of my German keyboard). Especailly those which allow you to fold/unfold at your current position. That makes navigating new projects so much easier.

kiranjd profile image
kiranjd • Edited

Fold everything: cmd/ctrl + k then 0

airmind profile image
Alex Ágreda

Ctrl + Shift + [ to fold
Ctrl + Shift + ] to unfold

anduser96 profile image
Andrei Gatej

Thanks for sharing! Didn't know about Wrap with Abbreviation, that's cool.

laxedo17 profile image

thanks. While not a shortcut, for errors, Error Lens is amazing! One of the best VS Code extensions.

simonpaix profile image
Mariana Simon Author

True! I love it too

tilkinsc profile image
Cody Tilkins

I swapped ctrl + d and ctrl + shift + d to delete line and duplicate line. I don't make that much use of selecting one by one. I use ctrl + shift + L which selects all alike more.

simonpaix profile image
Mariana Simon Author

Nice tip! Thanks, Cody

vince_amstz profile image
Vincent Amstoutz

Very interesting, I did not know them all, thanks ! 👍🙂

Also, I often use Ctrl + G to go to a particluar number of line.

simonpaix profile image
Mariana Simon Author

Nice. I didn't know about this one 👍

qq449245884 profile image

Dear Mariana Simon Paixao,may I translate your article into Chinese?I would like to share it with more developers in China. I will give the original author and original source.

simonpaix profile image
Mariana Simon Author

Hi there! Sure, I don't see any problem if you include the original author and source. Can you send me a link when you do so? I have Chinese friends and would like to share with them :)

qq449245884 profile image

no problem!

lokeshsenthilkumar profile image
Lokesh Senthilkumar

shift+alt+down to copy the current line

simonpaix profile image
Mariana Simon Author

Good one 👍

piotrnajda3000 profile image

Ctrl + K then V for Markdown preview / edit in split view.

youpiwaza profile image

Learned a few more. Thanks a lot ;)

Format all file instead of Palette > Reindent. that's cool

amanchourasia profile image
Aman Chourasia

Great! 👏

simonpaix profile image
Mariana Simon Author

Thanks, Aman!

designeranna1 profile image
Designer Anna

Shortcut to move line is my fav.
Thanks to share all these shortcuts. 😇

piotrnajda3000 profile image

Ctrl + Shift + K for removing a line!

loganliffick profile image
Logan Liffick

Wrap with abbreviation is a game changer, great list!

simonpaix profile image
Mariana Simon Author

Thanks, Logan!

gpakyoo profile image
Godluck Akyoo

Wrap with Abbreviation, just increased my efficiency by many folds, Thank you.

I would like to add Alt + Shift + Up/Down arrow duplicate line or a block of code selected.

simonpaix profile image
Mariana Simon Author

Thanks! Nice addition 👍

maneesh8040 profile image
Maneesh Kumar 🇮🇳


testerslol123 profile image
Danny S

Thanks for sharing, I just saw this post, and I will try it in my visual studio code.

The things that I always use is ctrl + P and ctrl + /

cespujunk66 profile image

thanks, very interesting!

sebasprogrammer2020 profile image

muchas gracias. el bonus estuvo super! thanks a lot

andrewbaisden profile image
Andrew Baisden

Great stuff!

gilfewster profile image
Gil Fewster

While not a shortcut, using regular expressions with the search box is staggering powerful and well worth exploring.

nostop8 profile image
Volodymyr Dovbenko

Before moving lines using alt+up or down, I usually use shift+up or down in order to select multiple lines. Saves some time too.

vjnvisakh profile image
Visakh Vijayan

Ctrl shift I was a new one for me. Thanks

mcwertgaming profile image
Damon Leven

This is a bit basic, but with STRG+shift+ARROW you can extend your cursor to write on multiple lines at the same time.

shubham57396755 profile image

Thanks for Sharing Very useful!

jonatannietoa profile image
Jonatan Nieto

Wrap with Abbreviation is a cheat that is very useful! Great post!

simonpaix profile image
Mariana Simon Author

Thanks, Jonatan! Yeah, I use it a lot!

julianperezpesce profile image
Julián Pérez Pesce

ctrl + k + c to comment multiple lines selected
ctrl + k + u to uncomment the multiple lines selected

samuel_marien profile image
Samuel Marien

Thanks, so useful !

simonpaix profile image
Mariana Simon Author

Thanks, Samuel!

faisalahammad profile image
Faisal Ahammad

Much appreciated