DEV Community

Cover image for Not using VS Code keyboard shortcuts? After this you will be.
Matthew Hassenboehler
Matthew Hassenboehler

Posted on

Not using VS Code keyboard shortcuts? After this you will be.

What are Keyboard shortcuts?

Let me preface this whole thing by saying this, I'm 90% sure you use keyboard shortcuts every day and it would bewilder me to find someone on this site that hasn't used a ctrl-c/ctrl-v once in their life. I also will be referring to PC binds mostly since that's what I own (just imagine I'm saying ⌘ for my Mac brothers and sisters). As the Microsoft Windows page would like to word it, "Keyboard shortcuts are keys or combinations of keys that provide an alternative way to do something that you’d typically do with a mouse." and you know, that's pretty on point. The meaning of term "keyboard shortcut" can vary depending on software manufacturer. In Windows, hotkeys consists of a specific key combination used to trigger an action (these are usually system-wide shortcuts that are available in all contexts so long as receiving program is active); mnemonics represent a designated letter in a menu command or toolbar button that when pressed together with the Alt key, activates such command.
Image description

How do shortcuts help us?

Anyway, keyboard shortcuts help us by doing literally what's in their name, providing us with a shortcut! It's incredibly handy to know even a minimal amount of these as anyone who uses a computer on daily basis since they quickly do what would take any amount of time longer. About to hit that refresh button at the top left? No way bozo, hit F5. Wanna find out what's going on in the task manager because your PC is dying? Ctrl+Shift+Esc. So without further ado, let's get into why you actually clicked on this blog...

Visual Studio Keyboard Shortcuts

So before I start telling you about specific shortcuts in general, by doing Ctrl+ K then Ctrl + S you open up a new tab named Keyboard Shortcuts that looks like this.
Image description

This tab shows you all of the default assigned shortcuts in the program, an astronomical amount of other commands, and best of all you have the ability to create or change keybinds that most suit you. This is great because you can assign your own shortcuts so they're easier to remember or for things that you feel you need more often than others.

Essential Shortcuts

Moving on I would like to talk about more common or essential shortcuts. These are shortcuts that are a bit more common and may also be applicable in other programs and such. In my current schoolwork after opening up VS Code the first thing I do is hit Ctrl + shift + `. This particular shortcut opens up a new terminal since mine usually opens without one. Some other great starter shortcuts are Ctrl + S for Save, Ctrl + C/V for Copy and Paste, and Ctrl + Z/Y for Undo and Redo. Lastly, a great shortcut for when debugging is Ctrl + /, as it will turn the line that your cursor is current on into a commented line of code and even better, if you highlight a chunk of code and then do it, it will comment out the entire highlighted section!

More Advanced Shortcuts

These shortcuts that I'm about to go over with you are a bit more specific, granted the above section did have some that may belong here. This first one I want to talk about is Alt + UpArrow/DownArrow. This shortcut is a tad different since it isn't a single input necessarily. If you hold down Alt, the line your cursor is will move up or down with it's respective Arrow key input. This can be great for just moving a line somewhere else while coding/debugging/etc. The next one also uses the arrow keys as it is Shift + Alt + UpArrow/DownArrow. This will copy the line your cursor is on either up or down. This can cut out time real fast instead of either rewriting the same line over and over or copy and pasting when you know you'll be using the same or a very similar line for multiple lines. The last one I'll be going over is also in this little family we've made with Alt and the arrow keys. This is the shortcut, Ctrl + Alt+ UpArrow/DownArrow. By pressing the up or down arrow key while holding the first two keys will add cursors to whatever lines you go across, giving you the ability to type on multiple lines at once. I can see it being useful when needing to fix multiple lines of code that happen to overlap, but I do feel like this one is a tad niche.

In conclusion..

Shortcuts can be incredibly helpful and speed up whatever we're doing be it actually coding or just surfing the web. I do implore anyone who isn't already using shortcuts to maybe try to implement just one in their next project and see how much they like it or how much it may improve their work-speed and if you're someone who already uses most of these or more, then I hope it was a somewhat fun read or that you might feel inspired to try more!

Sources:
https://unacademy.com/content/bank-exam/study-material/computer-knowledge/benefits-of-the-keyboard-shortcuts/#:~:text=For%20starters%2C%20they%20can%20help,switch%20between%20windows%20and%20apps.
https://en.wikipedia.org/wiki/Keyboard_shortcut
https://code.visualstudio.com/docs/getstarted/tips-and-tricks
https://www.youtube.com/watch?v=Xa5EU-qAv-I

Top comments (0)