I have the following sequence of vim commands I use to copy a function va{Vy, how can I map this to a shortcut key like F1? I'd also like to persist this.


1 Answer 1


The command would be:

nmap <F1> va{Vy

You can store this command in your ~/.vimrc file. This will make it persistent. If it does not exist simply create it.

More infos about this you can find here.

My question would be what should this command do? If you want to yank the current line the shortest commmand would be yy. If wou want to yank a paragraph (all text between an empty line) this does not work and the better command would be vipy. vip selects the current paragraph.

  • Well, the command is equivalent to yVa{, which yanks everything in { forced-linewise.
    – D. Ben Knoble
    May 17 at 20:56
  • Also: prefer nnoremap
    – D. Ben Knoble
    May 17 at 20:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.