10 Visual Studio Code editing shortcuts

omeal

Supriya Shashivasan

Posted on January 17, 2022

10 Visual Studio Code editing shortcuts

Visual Studio Code is a powerful tool that developers like us use on a daily basis for hours. It also is a favorite for a few of us as well. As we spend most of the time typing code, there are a few keyboard shortcuts that help in writing code faster.
In this article, I will be sharing 10 keyboard shortcuts that I use in Visual Studio Code to code faster and get by without using the mouse.

1. Cut, Copy and Paste

There are a ton of times when we use Cut, Copy and Paste while coding.

  • Cut : Command (or Cmd) ⌘ + X
  • Copy : Command (or Cmd) ⌘ + C
  • Paste : Command (or Cmd) ⌘ + V

Cut, copy, paste

2. Cursor to Start/End of line

Use this command when you want to move the cursor to the start/end of the line

  • Cursor to start of the line: Command (or Cmd) ⌘ + ←
  • Cursor to end of the line: Command (or Cmd) ⌘ + →

Cursor to start/end

3. Move line

This command is used to move the whole line up or down.

  • Move line up : Option (or Alt) ⌥ + ↑
  • Move line down : Option (or Alt) ⌥ + ↓

Move line

4. Add line comment

I have used this shortcut a lot of times. With the press of just two keys, I can cut down so much work 😁

  • Add line comment : Command (or Cmd) ⌘ + /

Add line comment

5. Select a line

This command is used to select the complete line. After the line is selected, we can use other shortcuts like Copy / Cut.

  • Select a line: Command (or Cmd) ⌘ + L

Select line

6. Copy line up/down

Use this shortcut to copy the whole like and paste it up/down

  • Copy line up: Shift ⇧ + Option (or Alt) ⌥ + ↑
  • Copy line down : Shift ⇧ + Option (or Alt) ⌥ + ↓

Copy line up/down

7. Move word by word

At times to reach a point in between a word, we find ourselves using to move to navigate to that point and placing our cursor. We can avoid this by using a shortcut that moves the cursor word by word.

  • Move the cursor to right: Option (or Alt) ⌥ + →
  • Move the cursor to left: Option (or Alt) ⌥ + ←

Move word by word

8. Select a word

This command is used to select a word. Further, this command can be combined with Cut/Delete or any other commands.

  • Select a word: Command (or Cmd) ⌘ + D

Select word

9. Multiline cursor

This is my favorite shortcut!! I was so glad when I figured out this shortcut existed, it reduced my time to edit code considerably. Using this shortcut you can place the cursor simultaneously at different places in the editor.
Here is how you use it - Press the Option key and with the mouse, click at various places where you want the cursor to be present.

  • Multiline cursor: Option (or Alt) ⌥ + click

Multiline cursor

10. Insert cursor above / below

This is similar to the multiline cursor shortcut. Here we do not use the mouse to click, but we use the arrow keys. Although, this is not as flexible as the click because the cursor moves up/down in a line.

  • Insert cursor above : Option (or Alt) ⌥ + Command (or Cmd) ⌘ + ↑
  • Insert cursor below : Option (or Alt) ⌥ + Command (or Cmd) ⌘ + ↓

Insert cursor above or below

Those are the shortcuts I usually use while I type away on my Visual Studio code editor. When starting to use shortcuts, you might feel confused or it might take a little time to get a hang of it. But once you practice and are used to using shortcuts, you will observe that editing code now takes much less time!! 😇

Tip : Incase you forget the shortcut, open the Command Palette and type in the operation you want to perform (eg : Copy, move line). Visual Studio Code shows the shortcut you can use on the righthand side in the dropdown.

Let me know the shortcuts you use in the comments below!!

Also, find me on Twitter !!

💖 💪 🙅 🚩
omeal
Supriya Shashivasan

Posted on January 17, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

10 Visual Studio Code editing shortcuts
codenewbie 10 Visual Studio Code editing shortcuts

January 17, 2022