When I use vim, I set my custom settings in ~/.vimrc like this:
command Noh noh
command NOh noh
command NOH noh
so that I can execute :noh, :NOh or :NOH, which would work just like :nohl.
Now I'm working with Vscode and I installed the plugin vscodevim 1.20.2. I want to make the same settings but I don't know how. I've tried as below but it's not working:
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": [
":NOH"
],
"after": [],
"commands": [
{
"command": ":nohl",
"args": []
}
]
}
]
I haven't been able to find a method to define custom commands with VSCodeVim, but if you split the
"before"value into an array of characters (i.e."before": [":", "N", "O", "H"]), you can simulate the desired behavior. It's somewhat hacky, since the normal-mode keybindings show up in a different place in the status bar, but it seems to work for me.Note that you also won't be able to use tab completions, since you're not defining a real Ex command, but you can use
"<Tab>"as a key in your"before"array, and it works. This way, you can use your command's most commonly-typed prefix, appended with"<Tab>", as the"before".Note also that VSCodeVim added experimental
vimrcsupport, which you could try. However, it seems like at least certain custom-defined commands fail to work.