vimtricks.wiki Concise Vim tricks, one at a time.

How do I make plugin commands repeatable with the dot command?

Answer

Plug 'tpope/vim-repeat'

Explanation

vim-repeat by Tim Pope extends the . (dot) command to work with plugin mappings. Without it, . only repeats built-in Vim commands.

How it works

  • Install the plugin
  • Plugin authors call repeat#set() in their mappings
  • Now . repeats the last plugin command

Example

With vim-surround and vim-repeat installed:

  1. ysiw" wraps a word in quotes
  2. Move to another word
  3. . wraps that word in quotes too

Without vim-repeat, . would not repeat the surround command.

Tips

  • Install: Plug 'tpope/vim-repeat'
  • Works with vim-surround, vim-commentary, vim-unimpaired, and more
  • No configuration needed — it works automatically
  • Plugin authors must support it for their commands to be repeatable
  • It is a tiny plugin with zero overhead

Next

How do you yank a single word into a named register?