Useful keyboard shortcut in vscode

Image: https://www.groovypost.com/tips/50-universal-web-browser-hotkeys/

It is important to learn helpful keyboard shortcuts that can save you a few seconds every time you use them in order to maximize the time you spend in front of a keyboard. It may feel uncomfortable at first, but if you use these shortcuts hundreds or thousands of times every day, you might be saving yourself hours of work each week.

Copy Cut Paste

Copyctrl + c
Cutctrl + x
Pastectrl + v

  • This is probably the most used shortcut when using a computer. We need to highlight the text first and then perform the shortcut. This is different in vscode,  If you just place your cursor on a line without highlighting anything and press ctrl + c it will copy the entire line your cursor is on including the line break. When you use ctrl + v, the entire line will be pasted above the current cursor line and ctrl + x also works the same.

Comment

ctrl + /

  • This shortcut is very useful for commenting or adding a new comment to your code. When we want to comment out a line of code, we need to put the correct set of tags or characters to comment on a line of code. For example, in HTML we comment a code by putting the code inside the <!–code here–> tag. Another example is in the javascript file, by putting // in front of the code, it will comment the whole line of code. This can be tedious to do it manually especially if you want to comment out multiple lines of code. Using the shortcut ctrl + / in highlighted code, it will add the correct tag or character to comment out the whole code. It also works in a non-highlighted code by placing the cursor you want to comment.

Open file within the project

ctrl + p

  • if you want to spend less time finding a specific file in a nested folder in your sidebar. This shortcut will prompt a search box to help you navigate your file easily.

Find In File/Project

ctrl + f
ctrl + shift + f

  • Although you’re probably already aware of the following shortcut, it’s still really useful. Simply press ctrl + f to search for a specific collection of text in the file you’re working on. This will open a search box that you may use to find all matches in your current file that match your search. By using the ctrl + shift + f, it will show a search box in the sidebar and you can now search a text from all the files in your project and see the file where the text is located.

Indent/Un-Indent Line of code

tab
shift + tab

  • It’s difficult to maintain consistent indentation in your code since it’s so easy to make a mistake, and repairing it by placing your cursor at the beginning of each line is inconvenient. By highlighting multiple lines of code and pressing tab, you can simply indent a group of code. This will make a one-tab indentation on all of the code lines. You can un-indent code by pressing shift + tab, which will remove one tab from all of the selected lines of code.

Create New File

ctrl + n

  • You will certainly create a large number of new files while developing new functionality. Normally, you’d use the mouse to choose the new file button, but you can also use the keyboard shortcut ctrl + n to create a new file. This will open a new file for you to work in right now.

Move Cursor whole word at a time

ctrl + left arrow
ctrl + right arrow

#or for more fast way
shift + home
shift + end

  • Because you sometimes need to change code in different locations of the same file, moving your cursor through the code is extremely crucial. Instead of using the mouse to shift your cursor to the left or right by a whole word at a time, use the shortcuts ctrl + left arrow and ctrl + right arrow. This is a great way to get to the end of a long word or a long line of code fast. When paired with the next shortcut, this shortcut becomes even more handy.
  • Using the shift + home and shift + end also make the highlighting of your code instantly.

Reference
https://www.c-sharpcorner.com/article/visual-studio-code-keyboard-shortcut-for-windows/

Leave a Comment

Your email address will not be published. Required fields are marked *