DEV Community

Pauline
Pauline

Posted on • Updated on

20 VS Code shortcuts to speed up your flow ⚡️

In this article I want to share some of my favorite and most used VS Code shortcuts that help me save time, make my life a little easier and, as a heavy keyboard user, also allow me to stay in my developer flow.

You may be familiar with some of them already but hopefully you will discover a new shortcut that you can introduce into your workflow starting right now. 🤞🏻

I jotted down the key combinations for Mac users. If you’re a Windows or Linux user, you can find the key bindings for your OS here.

Alright then, so without needing to select the entire line first...

  • ⌘X - cut a line
  • ⌘C- copy a line
  • ⇧⌘K - delete a line
  • ⌘L - select the line

And while your cursor is on a specific line..

  • ⌘Enter - insert a new line below it
  • ⇧⌘Enter - insert a new line above it
  • ⌥↑ and ⌥↓ - move the line up/down
  • ⇧⌥↑ and ⇧⌥↓ - duplicate line on the line above/below it
  • ⌘] and ⌘[ - indent and outdent the line
  • ⌘/ - (un)comment out the line

Or within a specific file..

  • ⌘D - find other instances of selected code
  • ⌥Z - toggle word wrap

Lastly, for some editor/window management..

  • ⌘P - find and go to file (quick open)
  • ⌘N - new editor
  • ⌘W - close editor
  • ⌘B - toggle visibility of the side panel
  • ` - toggle visibility of the integrated terminal
  • ⌘2 - split screen into two editor groups
  • ⇧⌘T - reopen recently closed editor
  • ⌥⌘← and ⌥⌘→ - view editor tab on the left/right

Happy coding!


If you enjoyed reading this post or if it was helpful to you, you can support me by buying me a coffee — I'd really appreciate it! 🙏

Latest comments (31)

Collapse
 
aarone4 profile image
Aaron Reese

Ctrl +k->c to comment selected lines
Ctrl + k->u to uncomment
// Comments in PHP,sql, TS and is. <!----> comments in html.

Collapse
 
kurd93 profile image
Kurd93

Useful, thanks with all appreciations.

Collapse
 
jameslivesey profile image
James Livesey

Ah that's very useful, thanks! 😀

Collapse
 
xdamiblock profile image
Damian Bocanegra

you can also use ⌘J to open up the terminal, I think it's easier that way

Collapse
 
anjankant profile image
Anjan Kant

Ctrl+Break ==> Build Cancel
Run Code Analysison Solution ==> Alt+F11
Break ALL ==> Ctrl+Alt+Break
Debug Start ==> F5

Collapse
 
dpliakos profile image
Dimitris Pliakos • Edited

Another one is to open second terminal Ctrl+shift+5
(let's say you have a gulp/grunt/webpack watcher that you want to see if it compiles)

Tip:
Terminal toggle is Ctr+ `

Collapse
 
jameslivesey profile image
James Livesey

I personally use Ctrl + K ➡️ Enter as it keeps the newly-opened tab sticky and non-replacable by other files when you open them too!

And of course — how could I forget — Ctrl + Tab to switch tabs!

Collapse
 
httpspauline profile image
Pauline

I didn't know about ctlr + tab, thanks for sharing!

Collapse
 
jameslivesey profile image
James Livesey

No probs! It also works with many web browsers too. Just about anything with tabs!

I'm not sure it applies to VSCode (tho I bet it does) but you can also do Ctrl + 1 to Ctrl + 8 to select tabs 1 to 8, and Ctrl + 9 to select the last tab.

Collapse
 
rjmunhoz profile image
Rogério Munhoz (Roz)

Here are two that I use quite often:
Command (ctrl) + K M - Switch file language
Command (ctrl) + Shift + L - Select all occurrences of a term on the current file

Collapse
 
rjmunhoz profile image
Rogério Munhoz (Roz)

Also, Command + Option + F on Mac to auto format the current file
I'm not sure about the equivalent for other platforms as I reckon it's completely different

Collapse
 
gregfox profile image
Greg Fox

⇧⌘D - duplicate the selected code.

Collapse
 
goyalaman profile image
goyal-aman • Edited

Hey there windows users!!! To use these shortcuts in windows on VsCode, replace
⌘ - ctrl
⌥ - alt
⇧ - shift

Collapse
 
thecaitcode profile image
Caitlyn Greffly

This is a great reference sheet! Bookmarked 🔖

Collapse
 
johnnyjab profile image
JohnnyJab

I am so grateful that you shared these, can't thank you enough for how much you just increased my productivity.

Collapse
 
purandarrao profile image
Purandar

How can I split a file in editor to an already existing right side editor.

Some comments may only be visible to logged-in visitors. Sign in to view all comments.