Have you ever realized that using a mouse reduces the speed of your development? Using a mouse slows down your speed because you should move your hand to the mouse and move back again to the keyboard. However, we can make both of our hands staying on the keyboard all the time if we know all the shortcuts. I'm still learning to stop using a mouse, and I want to share my most useful shortcuts in VS Code. These are important shortcuts that VSCode user must know to speed up your coding process.
Mac: Cmd ⌘ + Left Arrow / Right Arrow Win: Home / End
Mac: Option ⌥ + Left Arrow / Right Arrow Win: Ctrl + Left Arrow / Right Arrow
The main shortcut of highlighting is holding the
shift key + arrow or you can combine it with the shortcuts for moving the cursor.
Mac: Shift ⇧ + Cmd ⌘ + Left Arrow / Right Arrow Win: Shift + Home / End
Mac: Shift ⇧ + Option ⌥ + Left Arrow / Right Arrow Win: Shift + Ctrl + Left Arrow / Right Arrow
Mac: Cmd ⌘ + d Win: Ctrl + d
There are two ways to delete one line code.
Mac: Cmd ⌘ + Shift ⇧ + x Win: Ctrl + x
I am personally more convenient to use this, which is the
Mac: Cmd ⌘ + x Win: Ctrl + x
Mac: Cmd ⌘ + w Win: Ctrl + w
Mac: Cmd ⌘ + k w Win: Ctrl + k w
Mac: Cmd ⌘ + p Win: Ctrl + p
It will open a search bar, and we can type the file name there.
Mac: Ctrl ^ + tab Win: Ctrl + tab
Mac: Cmd ⌘ + \ Win: Ctrl + \
Mac: Cmd ⌘ + 1 / 2 / 3 Win: Ctrl + 1 / 2 / 3
1, 2, or 3 depends on the screen position, and if the split screen doesn't exist, it will open a new empty split screen.
Mac: Cmd ⌘ + b Win: Ctrl + b
Mac: Ctrl ^ + ~ Win: Ctrl + ~
VSCode palette will give you access to all VSCode functionalities and also all shortcuts. VSCode palette is powerful!
Mac: Cmd ⌘ + Shift ⇧ + p Win: Ctrl + Shift + p
We haven't discussed how we can add a new file or folder, delete a file, move a file, rename a file name, and duplicate a file. Unfortunately, VSCode doesn't have the built-in feature for that without going to the sidebar. However, I watch James Q Quick's video, and his video shares about the two useful extensions.
Mac: Cmd ⌘ + Shift ⇧ + p -> Type "File Utils" Win: Ctrl + Shift + p -> Type "File Utils"
By using File Utils, you don't need to open the sidebar all the time just type
File Utils in the VSCode Palette.
advanced-new-file extension is handy when you want to create a file or folder. File Utils provides a feature to add a file and folder, but I feel more convenient with this extension. I also create key binding for this extension
Cmd + n.
How to add a shortcut for the extension?
- Open VSCode palette
- Click the gear icon
- Click edit
- type the shortcut
Remembering all the shortcuts in a time is challenging, but if we push ourselves to use shortcuts on daily basis. We will remember all the shortcuts soon. I hope it would be helpful.
Please leave a comment on which the most useful shortcut for you? or do you have another useful VS Code Shortcut?