VS code has been one of the most used text editors now. Most of the developers prefer VS code for programming. VS code offers shortcuts and tricks that one can use to enhance their productivity significantly.
I will be listing some of the VS code shortcuts and tricks which you can also use for better productivity.
Adding multiple cursors is helpful when you have to edit the similar type of code in multiple places.
You can add the multiple cursors in the same document and edit at multiple lines simultaneously. Just press,
Alt + Click (mouse left click)
You need to hold the Alt key and click wherever you want the new cursor. After that you can start editing the document. The document will get edited everywhere you have added the cursor.
To add the cursor below or above the current position
If you need to add the cursor below or above the current position rather than any arbitrary position you can do it by,
Ctrl + alt + up arrow (for adding cursor upward) Ctrl + alt + down arrow (for adding cursor downward)
Control + option + up arrow (for adding cursor upward) Control + option + down arrow (for adding cursor downward)
Edit All Occurrences Of the Text
Let’s assume that you have some text which is all over the document and you want to edit all of them. Editing all of them one by one will be time consuming.
In VS code, you can change/edit all occurrences at once.
You can do this by selecting the text you want to edit and pressing Ctrl + F2.
select text then press Ctrl + F2
Control + F2
Also Check: Best Programming Language to Learn in 2021
Renaming a symbol in the Entire Project
This shortcut is almost the same as the previous one but it is helpful when we have to change the variable/symbol in the entire current working project. Doing it one by one manually will be really tiresome.
To rename all symbols at once you need to select the symbol and press F2.
select the symbol then press F2
Move current line up or down
You may need to move a line up and down frequently. You can easily move the line up and down on which cursor is currently on.
In windows, to move line up and on which your cursor is currently on press Alt + Up for moving up and Alt + Down for moving down.
Alt + Up (to move line up) Alt + Down (to move line down)
Option + Up (to move line up) Option + Down ( to move line down)
Copy Line Up or Down
You might have come across the condition when you need to insert the similar kind of statement as the previous one. For this either you have to type the whole line again or have to select the line then copy and paste it.
In VS Code, if you have to insert similar type of whole line as previous one you can,
Shift + Alt + Up (to add the same line below it) Shift + Alt + Down (to add the same line above it)
Shift + Option + Up (to add the same line below it) Shift + Option + Down (to add the same line above it)
The difference between copying the line up or down is the position of the cursor.
Also Check: Python Program Examples
Reopen closed Editor
When working in huge projects there are many tabs opened for many files. It is obvious in case you closed one of many tabs/editors accidentally and can’t track which one was closed. In VS Code, you can re-open closed editor,
Ctrl + Shift + T
Control + Shift + T
This shortcut opens the closed editors one by one. It acts as the undo feature for the closed tabs.
Show or Hide Integrated Terminal
You can show or hide integrated terminals of VS code without reaching up to the menu. You can do it by,
Ctrl + ` (backtick)
Control + ` (backtick)
If the integrated terminal is currently not showing then this shortcut will show up the integrated terminal. Similarly, if the integrated terminal is showing then using this shortcut will hide the terminal.
What if you want to create a new terminal?
This is as simple as the previous shortcut. You can create a new terminal by,
Ctrl + Shift + ` (backtick)
Control + Shift + ` (backtick)
These are few of my best shortcuts which are helpful during programming. It always feels good to save and invest the same time in other productive works. These VS code shortcuts will surely help you to stay more productive during programming.