DEV Community

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

Posted on • Edited on • Originally published at learnpine.com

10 useful VS Code shortcuts you should know ()

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.
errors

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.
multiselect

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.
one-select

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
format

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

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

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.
wrap

Honarable mention:

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

Β 

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 😁
Β 
Β 

Oldest comments (48)

Collapse
 
anduser96 profile image
Andrei Gatej

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

Collapse
 
shubhamb profile image
Shubham_Baghel

Thanks for Sharing Very useful!

Collapse
 
youpiwaza profile image
max

Learned a few more. Thanks a lot ;)

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

Collapse
 
chadyka profile image
Jakab ÁdÑm

Great article! 10. Shows the same gif as 4. though. Maybe you could correct that.

Collapse
 
simonpaix profile image
Mariana Simon

Thank, you! Jakab! I corrected that, thanks :)

Collapse
 
laxedo17 profile image
laxcivo

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

Collapse
 
simonpaix profile image
Mariana Simon

True! I love it too

Collapse
 
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
Collapse
 
who8mypnuts profile image
Stan

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

Collapse
 
faisalahammad profile image
Faisal Ahammad

Much appreciated

Collapse
 
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.

Collapse
 
vjnvisakh profile image
Visakh Vijayan

Ctrl shift I was a new one for me. Thanks

Collapse
 
iamthebuilder profile image
The Builder

Thanks for sharing