-1

As per the site https://github.com/tpope/vim-repeat, the procedure to enable repeat.vim is as follows:

silent! call repeat#set("\<Plug\>MyWonderfulMap", v:count)

But I don't understand the first argument of repeat#set function. Can you please explain with an example? If I want to configure repeat.vim along with surround.vim, what instruction should I include in .vimrc? And how will that instruction change for unimpaired.vim?

hjpotter92
  • 78,589
  • 36
  • 144
  • 183
Ken Russell
  • 2,348
  • 5
  • 24
  • 39

2 Answers2

2

you don't have to do much in your vimrc if you want surround to get supported by repeat, if you check the codes of surround, the repeat functions were called there.

And for the explanation of the function, you will find it in the link you wrote in the question. read here:

https://github.com/tpope/vim-repeat/blob/master/autoload/repeat.vim#L19

Kent
  • 189,393
  • 32
  • 233
  • 301
  • Should I paste the following verbatim in .vimrc? silent! call repeat#setreg("\MappingToRepeatCommand", v:register) – Ken Russell Dec 21 '13 at 18:03
1

You apparently have a wrong understanding of how repeat.vim works. You don't enable this by calling repeat#set() once (e.g. in your ~/.vimrc); rather, the mapping itself must be modified to invoke repeat#set() after the mapping's normal work is done.

The way the repeat.vim plugin works is that each mapping has to tell it: Hi, I'm <Plug>MyMapping, and I just got executed. The repeat.vim plugin hooks into the . command, and if the last command came from such a mapping, it gets re-executed = repeated.

Therefore, repeat.vim support requires the cooperation of the plugin (which defines some mappings); either a plugin has it, or it hasn't (and then you have to ask the plugin's author to provide repeat.vim support, or use an external plugin like my repeatableMapping plugin to modify the mappings after-the-fact.

But, as Kent has already stated, the surround plugin comes from the same author as repeat.vim, and it already has that support built-in.

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
  • Thanks for the clarification. Then I guess the following plugins doesn't require explicit repeat.vim: surround, speeddating, abolish, unimpaired and commentary. Can you explain what "" stand for? Can you give an example? I think it will be a great help if you can provide an example and explain each part of the mapping. – Ken Russell Dec 22 '13 at 12:08
  • `` is just a special prefix that will never come from the keyboard (i.e. typed by you directly), so it can be used for abstractions. Find more in Vim's extensive help at `:help ` – Ingo Karkat Dec 22 '13 at 13:27