sponsor Vim development Vim logo Vim Book Ad

intermediate Tip #808: how to overwrite a visual-block of text with another such block

 tip karma   Rating 17/10, Viewed by 1222 

created:   October 24, 2004 12:11      complexity:   intermediate
author:   Chip Campbell      as of Vim:   5.7

One may overwrite a visual-block of text with another visual-block of text by:

   1.  Pick the first block: ctrl-v move "ay
   2.  Pick the second block: ctrl-v move c ctrl-o "aP <esc>


 rate this tip  Life Changing Helpful Unfulfilling 

<<Backing up and commenting .vimrc | GNU\Linux - gvim as an external editor >>

Additional Notes

[email protected] - NOSPAM, October 25, 2004 12:00
Based on the current tip, I've added a little extension to visswap.vim which allows one to
* select a region using ctrl-v + motion (visual block)
* hit <escape>
* move cursor to another location, hit \vr  (the backslash is actually <leader>, so folks may customize that easily)

That sequence will replace the text in a visual-block fashion below the cursor.  One may repeat the
\vr multiple times for additional replacements.

For visswap.vim, see:

http://mysite.verizon.net/astronaut/vim/index.html#VimFuncs
     under "Visual Mode Based Swapping"
nsg21 at hotmailcom, December 8, 2004 12:42
To make second block exactly same size as first instead of <Ctrl-v>move hit 1<Ctrv-V>
This will make a rectangular selection of exactly same size as previous one using current cursor position as top left corner. Unfortunately it does not (always? yet?) work with multibyte encodings, sobe carefulif you use them.
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to [email protected] after searching the archive. Help Bram help Uganda.
    stats
Sponsored by Web Concept Group Inc. SourceForge.net Logo