History Report a problem
Article Edit this page Discussion

Replace a visual-block of text with another such block

From Vim Tips Wiki

(Redirected from VimTip808)
Jump to: navigation, search
 

Tip 808Previous TipNext Tip

Created: October 24, 2004 Complexity: intermediate Author: Chip Campbell Minimum version: 5.7 Karma: 90/29 Imported from: Tip#808


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

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

[edit] Comments

 

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 (under "Visual Mode Based Swapping"):

http://mysite.verizon.net/astronaut/vim/index.html#VimFuncs


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, so be careful if you use them.


Rate this article:

Share this article:

Hubs Highlights International Sites Wikia messages
Entertainment
Gaming
Cartoons & Comics
Science Fiction
Hobbies
Sports
See all...
Grand Theft Auto
Doctor Who
Legend of Zelda Wiki
Terminator Wiki
Everquest II Wiki
Mystery Science Theater 3000
German
Spanish
Chinese
Japanese
More...
Wikia is hiring for several open positions
Send this article to a friend
"Replace a visual-block of text with another such block"
 
 
Hi!

I thought you'd like this page from Wikia!

http://vim.wikia.com

Come check it out!
Send confirmation