prepend to visual block not working in vim

后端 未结 3 1428
被撕碎了的回忆
被撕碎了的回忆 2021-01-14 23:25

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

相关标签:
3条回答
  • 2021-01-14 23:45

    It may be as simple as not having the right package installed. Visual block mode is not included in vim-minimal which is often the default version of vi. If you do this:

    rpm -qa | grep vim
    

    and you see vim-minimal but not vim-enhanced, then you have to install vim-enhanced. That will get you visual block mode as well as many other additional features.

    0 讨论(0)
  • 2021-01-14 23:49

    The behavior you describe with gvim on windows is quite unexpected. I would expect the inserted text to appear only before the first line. If you do want to insert a string before all the lines of the currently selected visual block, the natural thing to do is:

    :s/^/inserted text
    

    (Note that when you type :, vim will automatically set the addresses with :'<,'>, so the actual command will be :'<,'>s/^/inserted text)

    0 讨论(0)
  • 2021-01-15 00:00

    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
    
    0 讨论(0)
提交回复
热议问题