Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim VS Code Extension: How to remap "i" in normal mode to Escape key?

So I want to remap "i" to escape key since i find it easier to remember. But when I do this to settings.json of the VS Code:

"vim.normalModeKeyBindings": [
     {
        "before": [
            "i"
        ],
        "after": [
           "<Esc>"
        ]
     }
] 

The "i" key is disabled and nothing happens. Just the "i" key in insert mode being disabled. Help, I'm new to vim.

like image 371
Harvey Avatar asked Sep 19 '25 10:09

Harvey


1 Answers

In Vim, the i keybinding is used to go into insert mode from normal mode. The esc key is usually used to go into normal mode. Setting i as esc is definitely an anti-pattern. Usually people set CapsLock as esc key since it's nearer to the home row in keyboard and you don't have to reach as far as esc key, and since it's annoying sometimes. I have also seen some people using jj over esc.

Nevertheless, to answer your question, just open Preferences: Open Keyboard Shortcut from command palette(Ctrl+Shift+p) and search for vim_escape. Then double click on it and enter the key i and then press enter again. That should get you the desired result.

Again, suggesting you to not go ahead with this remapping.

like image 61
Yedhin Avatar answered Sep 23 '25 03:09

Yedhin