James M. Lay James M. Lay - 6 months ago 17
Linux Question

prepend to visual block not working in vim

I'm really fond of this idea of using Ctrl-V (Ctrl-Q in windows) to modify a visual block. The technique is explained here: In Vim how do I effectively insert the same characters across multiple lines?

For some reason, this is not working for me in VIM 7.2.411.

I press Ctrl-V, it says visual block, and I press J several times to expand my selection. Then I press Shift-I to insert, place my text, and when I press Esc, it has only modified the top line of the selection. I've had a hard time figuring out why this isn't working on my linux box. The same technique works great for gvim in windows.

What might be preventing this from working, or what should I try differently?

Answer

The source of the problem was lack of compiled support (thanks to my shared hosting provider). For others who are having a similar problem, check vim for the +visualextra option. You can check from normal mode with:

:echo has('visualextra')

It will return a "1" if it does. Otherwise you can look using:

:version

Or by invoking the --version option from the commandline:

vim --version | grep visualextra