DEV Community

Cover image for VS Code - Amateur to Pro 2
Garima
Garima

Posted on • Updated on

VS Code - Amateur to Pro 2

VS Code Productivity tips and speed hacks - 2

  1. Move around quickly

Command palette is awesome but it doesn't help you write your code faster, when you see a line of code you want to edit the natural approach is to select and highlight that line. A developer might do this 100s/1000s of times a day.

A faster way to get to where you want to edit is to hit ctrl + go followed by the line number you want to edit, from there use the arrow keys to move character by character and start editing.

cmd+g

  1. Multi-line editing

If you want to edit a word in multiple lines at the same time when the cursor lands on the word you want to edit with the help of the above-mentioned method hit ctrl + d or cmd + d again and again to select the same word. And now you're a 3x developer editing multiple lines of code at the same time.

In some cases you may want to use the mouse to select multi-line editing in such cases hold the alt or option key and click on different parts of the code in different lines where you want to edit, the editor will then set cursors in multiple places which will be then useful and easy to use for writing repetitive codes.

Multi line editing

Multi line editing

  1. Delete or move a line

If you want to delete a line from VS Code and paste it somewhere else the amateur approach is to highlight and select the line hit ctrl+x or cmd+x to cut the line and paste it with ctrl+v or cmd+v where you want to paste it.

But a better approach to do that is if you already have your cursor on the line you want to cut hit ctrl+x or cmd+x to cut the line not highlighting it required. Or if you want to paste that line above or below you can simply move the line with option/alt + up arrow/down arrow. Or if want to copy the line down by hitting the command available in your VS Code keyboard shortcuts.

  1. Custom snippets

In many projects, you may find yourself writing the same boilerplate again and again if you find yourself doing that a faster way to increase your productivity is to add a custom snippet.

From the command palette run the configure user snippet command. You can create global projects to use them across all over your project, now you edit this JSON file to add your snippets.

And now in your file, you can use the insert snippet command to insert your snippet. But if you work with a popular framework there are chances someone might have done that already for you. Before you build yours go into the extensions section and check out for your language snippets if available.

command palette

command palette

Snippet

  1. Auto-create directory/file

If you need to create a file in a folder that doesn't exist yet you can create that file by clicking on the create new file button, writing the file name with the nested directory names on top of it by putting a slash in front on them to separate them and VS Code will automatically create those directories.

Auto create directory/file

Auto create directory/file

Let me know in the comments below the productivity hack you use to boost your productivity.

Want to connect?

twitter · blogs · portfolio · email · linkedin

Top comments (0)