Search code examples
visual-studio-codevscodevim

VSCode Vim: map to function key


I'm trying out VSCode Vim and I'm having trouble remapping <leader>d to a Go To Definition action.

I've found that F12 is a Go To Definition shortcut in VSCode - now I'd like to set up a mapping from <leader>d to F12 but I can't figure it out.

I've tried the following without luck:

    "vim.normalModeKeyBindings": [
        {
            "before": ["leader", "d"],
            "after": ["<F12>"]
        }
    ]

I can see VSCode Vim capturing the leader command when in normal mode on one of my golang files but then when I hit d nothing happens. However, if I manually invoke F12 then I can see VSCode navigate to the definition of the symbol under the cursor.

What's the correct way to set up this mapping?


Solution

  • Found another way to achieve this:

            {
                "before": ["leader", "d"],
                "commands": [
                    "editor.action.revealDefinition"
                ]
            },