9 VS Code shortcuts programmers want you to use.

Oscar Näzell
4 min readJun 22, 2022

--

Photo by Robert Bye on Unsplash

Copy line without selection (CTRL + C)

Press CTRL + C without selecting any text and the entire line will be copied. You can now press CTRL + V to paste it as you please. This is a quick method of duplicating an entire line of code.

Ctrl + C without selection

Ctrl + L to select current line

This is another useful shortcut. It selects the current line and places the cursor at the start of the next line. It is super useful in combination with DELETE if you quickly want to remove a line because it will not leave you with an empty line. It can also be used with the next shortcut!

Ctrl + L followed by DELETE

Alt + Arrow up/down key to move line(s)

This shortcut is great if you need to reverse the order of your code. Note that it only moves full lines, so even if you select only part of a line it will move the entire line. I use it a lot when I need to reorganize sections in a file.

ALt + arrow down then arrow up

Shift + Alt + Arrow up/down key to duplicate selection

Similar to the previous shortcut, but instead it will duplicate the the content either above or below the section depending on the arrow key pressed. Neat shortcut if you want to duplicate large sections in a file.

Shift + Alt + Arrow down to duplicate the selected elements

Ctrl + D to select next occurrence of your selection

This is one of my most loved shortcuts. Very useful when you want to rename a variable in multiple places at once. You start of by selecting a piece of code, then as you press the shortcut, the next occurrence will automatically get selected and another cursor will be placed at the end of that selection. You can press the shortcut multiple times and then edit all selections at once.

Ctrl + D (4 times) to select edit multiple places at once

Ctrl + Enter for new line without line break

I don’t know how many times I have placed the cursor at the end of my line with my mouse and then pressed enter, before I discovered this shortcut. You can start of with the cursor placed anywhere in a line of code. As you press the shortcut, a new line will be created below the current line and the cursor will move to the new line. Neat.

Ctrl + Enter to create a new line

Ctrl + P for easier file navigation

If you are still navigating between files using your mouse in the file tree, you need to start using this shortcut. The shortcut will open a search bar in which you can simply search for the name of any file in your project. Use the arrow keys to navigate between the suggested files and press enter to open up the selected file.

Ctrl + P for quick file navigation

Ctrl + G for go to line

This is a useful shortcut if you want to avoid the scrollwheel of your mouse completely. Simply press this shortcut and then type the line number you wish to move to. Note that the file will scroll to the line number you have written before you press enter, so that you can edit your entry to move to another location.

Alt + left/right arrow for cursor history

If you are an avid mouse user and have extra buttons on your mouse, you might already be familiar with the backwards and forwards feature on those. The same feature is available with this keyboard shortcut. It is super useful if you have recently navigated between multiple files or sections of code and need to revisit those sections. Each press of the shortcut will move to cursor to the previous (left arrow) or next (right arrow) cursor placement, even across files. Forgive my use of the ☠mouse☠ here, I had to illustrate how a user would interact in different sections because I could relocate with the shortcut.

Alt + left arrow to move back to my two previous locations

Thank you for reading my third story! 😍 I hope you liked this new format where I illustrate using GIFs. I'm experimenting with different styles to see what feels best, so let me know what you think in the comments below. Cheers!

--

--