I want to map something like gi to open a Typescript interface implementation for example. In VsCode the shortcut is Ctrl + F12 and I tried to add a map like this inoremap gi <C-F12>
in .vimrc file but that does not work.
I also tried to do that in my settings.json but still no results.
"vim.insertModeKeyBindings": [
{
"before": ["g", "I"],
"after": ["<C-F12>"]
}
]
How can I do that?
You can achieve that by mapping a shortcut to a VSCode command, not a set of keys. If you look at VSCode shortcuts, you can see that the Go To Definition action is related to a command so you can take that command and map to a vim shortcut in your settings.json file.
In the example I will map gI
to editor.action.goToImplementation
which is the related command.
"vim.insertModeKeyBindings": [
{
"before": ["g", "I"],
"commands": ["editor.action.goToImplementation"]
}
],
"vim.normalModeKeyBindings": [
{
"before": ["g", "I"],
"commands": ["editor.action.goToImplementation"]
}
]