2

I need to copy the word under cursor, navigate to a different word in the document and replace it with the previous one I copied.

I do this so often that I use some custom key bindings for this.

f maps to yiw (Yank In Word)

ff maps to viwp (Select In Word with Visual mode and Paste)

So I can just f to copy, navigate and ff to replace the word.

How can I specify this custom remapping on VSCodeVim ?

I tried pasting the following into settings.json, (and a few other using commands with the editor. prefix) but I can't get it to work.

"vim.normalModeKeyBindings": [
    {
        "before": ["f"],
        "after": ["y", "i", "w"]
    },
    {
        "before": ["f", "f"],
        "after": ["v", "i", "w", "p"]
    }
]
rranjik
  • 690
  • 9
  • 21

1 Answers1

2

try assign another hot key instead of ["f", "f"], I use ["<leader>", "s"] and it works well. I guess two consecutive f key is confusing vscode with the f key in your copy tuple

royce
  • 21
  • 3
  • Thanks for your answer Royce. I works indeed. However, I would be nice if I could just map it to "ff", as I find this easier personally and I use it with plain vim all the time. I ended up using a different (single) key instead ("f" -> "yiw" and "n" maps to "viwp"). I will up-vote your answer, however. – rranjik Feb 28 '20 at 23:39