12 VS Code keyboard shortcuts to make your coding life much easier .(Macbook)

Beksultan Kaiypov
4 min readJan 28, 2021

The most effective way to make it easier for yourself to work in Visual Studio Code is to use keyboard shortcuts. In this blog, I’m going to talk about twelve very useful shortcuts in VS code to make your workflow faster and efficient.

1.Adding a comment:

command + /

As you know, to add an explanatory comment, you need to place the cursor at the beginning of the line and write a double slash there. But this slows down the process. It is much more convenient to press “command + /”, because you can do this anywhere in the line. And if the line was already a comment, you can comment back the line with the same shortcut.

2.Move to a specific line:

control + G’

Imagine that debuggers tell you that there is a catastrophic global error on line 846. If you start flipping and manually looking for this X location, it will take too long. Instead, just use the combination ‘control+ G’, specify the number of the desired line and, without too much fuss, start saving the world.

3.Swap lines:

“option + arrow”

If everything does not go according to plan, and you do not want to rewrite all the code from scratch, sometimes the solution to the problem can be a simple change of lines in places. If you need to place a line one position up or down, use the “option + arrow” in the direction of movement.

4.Duplicate Line Down/Up:

Shift + option + arrow up or down

A lifesaver for those who are tired of selecting-copying-pasting the same line of code over and over again.

5.Find paired parenthesis:

Shift + command + \

It is very easy to get confused with a lot of code. Sometimes it becomes unclear which parenthesis refers to which block, what begins and ends where, and what is generally going on on the screen. In this case, you need to use the above keys — this is a very useful addition to the existing highlighting pairs of parenthesis.

6.Renaming a variable:

F2

Imagine you’ve been writing your code the whole day, and then a senior developer came and said that it was a bad idea to name variables with English alphabet letters. Now what: go through the entire document and correct each one manually? Why, if there is a magic key F2.

7. Refactoring your code:

Shift + option +f

You can select a block or the whole file of code and use the above shortcut. It will automatically refactor your code and make it look nice and formated: everything will remain in place and readability will remain.

8.Find variable declaration:

F12

If it became unclear to you what kind of variable is in front of you and where it came from, select it and press F12 — this will take you to the place of the declaration, even if it is in a separate file.

9.On / off word wrapping:

option+z

It’s a matter of preferability. If you do not like that the text does not fit in width in the editor window, turn on word wrap.

10.Select the current line in the cursor:

command + L

If you need to select the whole line of code you can use the shortcut above.

Also if you need to select the whole file, you use “command + A” shortcut.

11. Multi-Select:

command + D

So you plan to change all of your H2 tags to H3 tags. So do you go through and pick and change each one? Oh, no. You multi-select them all, and in one take, change them all.

12.Move the whole block of code left or right:

command + ] or [

--

--