As a codeNewBie I realised the importance of shortcuts as soon as I started programming. Shortcuts not only allowed me to code quicker but it also helped me stay on my keyboard instead of reaching out to my mouse every time, which at times does start to get annoying. If you are a codeNewBie like me then I would highly suggest you to learn the shortcuts below:
Basic shortcuts
You should know the following shortcuts regardless of whether you are learning how to code or not. These shortcuts work everywhere and not particular to VS Code.
Select All
- Mac - ⌘ + A
- Windows - Ctrl + A
Copy
- Mac - ⌘ C
- Windows - Ctrl C
Paste
- Mac - ⌘ + V -
- Windows - Ctrl + V
Save current file
- Mac - ⌘ + S
- Windows - Ctrl + S
Undo last action
- Mac - ⌘ + Z
- Windows - Ctrl + Z
Open file
- Mac - ⌘ + O
- Windows - Ctrl + O
Close window/tab
- Mac ⌘ + W
- Windows - Ctrl + W
Search for keywords on your current document
- Mac ⌘ + F
- Windows - Ctrl + F
VS code specific shortcuts
As soon as I open my VS code editor I always try to make sure I practice the following shortcuts:
Sidebar open/close
- Mac - ⌘ + B
- Windows- Ctrl + B
Open new tab
- Mac - ⌘ + N
- Windows - Ctrl + N
Cut line (copies the line and removes it)
- Mac - ⌘ + X
- Windows - Ctrl + X
Quick Fix [Suggests spelling correction if code spell checker plugin is installed]
- Mac - ⌘ + .
- Windows - Ctrl + .
The beginning/end of a code line
- Mac - ⌘ + ←/→
- Windows - Ctrl + ←/→
The beginning/end of the file
- Mac - ⌘ + ↑/↓
- Windows - Ctrl + ↑/↓
Move from one window to another window
- Mac - ⌘ + Tab
- Windows - Alt + Tab
Split the code editor
- Mac - *⌘\*
- Windows - *Ctrl\*
Go to line (e.g. 6, would take you to line 6 of your code file)
- Mac - ⇧ + G
- Windows - Ctrl + G
Delete an entire line
- Mac - ⇧ + ⌘ + K
- Windows - Ctrl + Shift + K
Move current line up/down
- Mac - ⌥ + ↓ / ⌥ + ↑
- Windows - Alt + ↓/↑
Create multiple cursors
- Mac - ⌥ + click
- Windows - Ctrl + click
Opens the last tab you closed
- Mac - ⇧ +⌘ + T
- Windows - Ctrl + Shift + T
Select each character right or left
- Mac - ⇧ + ←/→
- Windows - Shift + ←/→
Select each word right or left
- Mac - ⌥ + ←/→
- Windows - Alt + ←/→
Redo last action
- Mac - ⇧ + ⌘ + Z
- Windows - Ctrl + Shift + Z
These are all I can remember off the top of my head at the moment but if you have any other recommendations or useful shortcut suggestions please let me know.
Top comments (8)
Another shortcut I've been using a lot is
- Mac -(while selecting a text) ⌘ + L- Windows - (while selecting a text) Ctrl + LIt selects all texts similar to your currently selected text.
Edit.
My bad, the above is wrong. It's supposed to be
I have seen this shortcut before and it would have been a really amazing shortcut only if it was working on my mac. For some reason everytime I press ⌘ + L it says, waiting for second key of chord..
Any idea why this might be happening?
My bad, what I initially commented was wrong. Check my edit
hehe no worries. I would prefer ⌘ + D as it's easier for me to remember. I should add it to my shortcuts :D Thank you
In windows it was ctrl + d I think
I have just tried ⌘ + D and it did something quite interesting. If clicked once, it selects all the similar word, and if clicked twice it creates multiple cursors on the selected texts, which is really interesting!! Thank you
Thanks for the list :-)
Two Windows shortcuts are wrong (at least for me?):
The beginning/end of a code line: Ctrl + Pos1 / End
Split the code editor: Ctrl + ^ (maybe only for non-US keyboard layouts?)
Hey Jannik, it might depend on your keyboard layout unfortunately because it seems to working on other windows systems :(