Is it possible to map custom commands in the Vim editor?

As a Vim enthusiast, I really appreciate that CodinGame allows us to use Vim key bindings! However, most of us tend to remap the key to something else to make it easier (and faster) to exit INSERT/VISUAL/SELECT modes and return to NORMAL mode. I for example map jk, kj, Jk, […] to it.

When I realised you could configure the editor like VS Code, I immediately tried copy-pasting my configuration which does the remapping (I use VS Code with the Vim extension). However, as expected, it did not do anything and I still have to hit to return to NORMAL mode.

I don’t know how the Vim key bindings are implemented on your editor, but it would be amazing to offer compatibility with the “vim.normalModeKeyBindings” and “vim.insertModeKeyBindings” (and other variations) options of the Vim extension of VS Code. Or maybe there’s already a way?

Hello,

We use https://github.com/brijeshb42/monaco-vim and not the vscode extension.

It’s not supported for the moment but it might come since it’s simple to implement, we’ll see :wink:

Oh awesome! It seems to support exactly that: https://github.com/brijeshb42/monaco-vim/issues/67

Hope to see it implemented one way or another soon!

Ok, it should work now (only the mapping, not the command trigger feature, and only the recursive ones)

Amy update on that feature?

What do you mean by this? Is it somehow possible to use jk to exit insert mode?

To exit insert mode with jk add this to your config :

“vim.insertModeKeyBindings”:[
{“before”: [“jk”], “after”: [“”]}
]

1 Like

Thanks for the pointer moustario! I had to change the weird double quotes to normal double quotes and add “” as an actual “after” value, but now it works great. Final solution:

"vim.insertModeKeyBindings":[ {"before": ["jk"], "after": ["<Esc>"]} ]

1 Like