Babak K. Shandiz
Babak K. Shandiz's Blog

Babak K. Shandiz's Blog

Basic Vim Shortcuts in VS Code

Babak K. Shandiz's photo
Babak K. Shandiz
ยทJul 2, 2021ยท

2 min read

Vim is great. Once you've mastered its brilliant way of cursor navigation and get used to some basic keyboard shortcuts, you'll uncover a significant improvement in your coding time productivity. Maybe that's a bit exaggerated, but still the effort surely pays off.

However, I use VS Code in my daily work and am too satisfied with it. To name a few, simplicity, great performance, rich set of commands, diverse extensions and support for various languages are among the top revered characteristics of VS Code.

Vim in VS Code

Some time ago, I wondered if I can mix the merits of Vim into VS Code, so spent my time on test driving several extensions. The result was not promising. Actually, for me, the most wanted feature of Vim was its cursor navigation method but the extensions provided many more Vim-like features which necessitated more complicated user interaction. Disappointed of extensions, I set out to define my own customized keyboard shortcuts to make things work as expected. Surprisingly it worked well and got improved over time which is why I've gradually got addicted to it.

In this post I'm listing my configured keyboard shortcuts, hoping you'll find them beneficial to your productivity. I'll be glad to hear your suggestions. ๐Ÿ’š

Shortcuts โŒจ๏ธ

The table below shows various navigations and their corresponding keyboard shortcut. I've listed the content to be appended to your keyboard.json file at the end of the post.

ActionShortcutNew shortcut
Cursor/item leftleftctrl cmd h
Cursor/item downdownctrl cmd j
Cursor/item upupctrl cmd k
Cursor/item rightrightctrl cmd l
Word leftctrl leftctrl cmd alt h
Word rightctrl rightctrl cmd alt l
Move to line beginninghomectrl alt 0
Move to line endendctrl alt 4
Delete previousbackspacectrl cmd space
Delete nextdelctrl cmd shift space

๐Ÿ‘ You can also use these shortcuts on file explorer, sidebar lists/trees (e.g., find in files or source control,) auto-completion lists and breadcrumbs.

๐Ÿ‘ Hold shift and/or alt keys with these shortcuts to select text or move by word.

๐Ÿ‘ Hold alt keys with delete next/previous shortcuts to delete by word.

๐Ÿ‘ To use shortcuts on the command palette lists, you need to first press tab key.

Get the shortcuts

Type and run Preferences: Show Keyboard Shortcuts (JSON) in the command palette which opens A JSON file named keybindings.json. prepend the content of this Github Gist to it, save, and you're done; this way currently defined shortcuts won't affect.

Share this