VSCode Productivity Tips & Hacks
Visual Studio Code is the most popular Integrated Development Environment globally. According to Stack Overflow’s 2023 Developer Survey, ~74% of developers prefer VS Code over others.
Reference: Stack Overflow’s 2023 Developer Survey
1. Open in VS Code
To open a project in VS Code:
- On Linux-based distros like Ubuntu, use the terminal command
code .
. - On Windows, open a folder by typing
cmd
in the address bar, pressing enter, and then usingcode .
.
A simpler method is to enable the ‘open with code’ option during VS Code installation, allowing the right-click context menu to open folders in VS Code.
If this config was missed initially, re-run the VS Code setup and ensure all checkboxes are checked. Previous configurations remain unchanged.
2. Renaming
Refactoring is essential for improving project quality and maintainability. VS Code facilitates this with the Rename Symbol command (F2).
- Press F2, type the new name, and press Enter to rename all instances of the symbol across files.
3. Multi Cursor
Multi-select cursor allows editing multiple locations simultaneously.
- Alt+Click: Place a new cursor.
- Ctrl+Alt+Down: Add a cursor below.
- Ctrl+Alt+Up: Add a cursor above.
- Drag mouse while pressing the mouse wheel.
Use these shortcuts to append text at the end of multiple lines.
Additional shortcuts:
- Ctrl+Left: Move cursor one word left.
- Ctrl+Right: Move cursor one word right.
- Ctrl+Backspace: Delete one word left.
- Ctrl + D: Add cursor to next matching word.
For renaming values with preserved case, use the ‘Multiple Cursor Case Preserve’ extension.
4. Move Lines Up/Down
Move lines with:
- Move lines up: Alt + Up Arrow
- Move lines down: Alt + Down Arrow
5. Copy lines Up/Down
Copy lines with:
- Alt + Shift + Up/Down Arrow.
To copy a line to a non-adjacent location, use Ctrl + L to select the line, then copy and paste.
6. Delete the Line
Delete a line quickly with:
- Ctrl + Shift + K.
Alternatively, use Ctrl + X to cut the line.
7. Comment Code Block
Commenting code blocks:
- Single-line comments: CTRL + /
- Multi-line comments: ALT + SHIFT + A
8. Code Navigation Backward and Forward
Navigate code with:
- Backwards: Ctrl + -
- Forwards: Ctrl + Shift + -
Customize key bindings via File -> Preferences -> Keyboard Shortcuts
.
9. Quick Open
Open a file quickly with:
- Ctrl + P
Navigate recently opened files or search by name.
10. Command Palette
Access all VS Code commands with:
- Ctrl + Shift + P
11. Global Find
Search within the codebase with:
- Ctrl + Shift + F
Filter search areas via the advanced menu.
12. Fast Scrolling
Scroll quickly by holding the Alt key while scrolling.
Adjust scroll speed with the editor.fastScrollSensitivity
setting.
Bonus: Open terminal outside VS Code with Ctrl + Shift + C
These shortcuts enhance daily productivity in VS Code.