Vim Plugins, surround.vimHere comes the second post in the article series "Vim Plugins You Should Know About". This time I am going to introduce you to a plugin called "repeat.vim".

Repeat.vim fixes an important functionality problem in the surround.vim plugin that I wrote about last week. The problem with surround.vim lies in the repeat command "." (dot). If you had applied a surrounding and wanted to repeat it with the "." command, it wouldn't work. This plugin fixes this problem.

So basically, whenever you install surround.vim, you also want to install repeat.vim with it.

There is one catch, though. It does not repeat visual or "ys" commands. Luckily, the "ys" commands can be often be substituted with "cs" commands. For example, if you wanted to do several "ysw"" (wrap a word in quotes), you may type "csw"" and then use "." commands to repeat. The only way to repeat visual commands is to record a macro.

Here is an example usage of the repeat.vim script. Suppose you had typed a sentence and you wanted to wrap all the words in quotes:

<strong>|</strong>foo bar baz quux muux woox

(<strong>|</strong> is cursor)

Type csw&#34:

<strong>|</strong>&#34;foo&#34; bar baz quux muux woox

Now press W.

&#34;foo&#34; <strong>|</strong>&#34;bar&#34; baz quux muux woox

W moved to the next word and . repeated the wrapping command.

Now do the same 4 more times, and you have the whole line wrapped:

&#34;foo&#34; &#34;bar&#34; &#34;baz&#34; &#34;quux&#34; &#34;muux&#34; &#34;woox&#34;

How to install repeat.vim?

  • 1. Download repeat.vim to ~/.vim/plugin (on Unix/Linux), or ~\vimfiles\plugin (Windows).
  • 2. Restart Vim or source repeat.vim with ":so ~/.vim/plugin/repeat.vim" on Unix or ":so ~/vimfiles/plugin/repeat.vim" on Windows).

Have Fun!

Have fun with surround.vim + repeat.vim. I'll write about a much more life-changing plugin the next time. :)