Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to map "Go To Implementation" using VsCode Vim?

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?

like image 692
Jancer Lima Avatar asked Nov 30 '25 12:11

Jancer Lima


1 Answers

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"]
    }
  ]
like image 98
Jancer Lima Avatar answered Dec 04 '25 11:12

Jancer Lima



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!