Wednesday, 2 September 2009

 

Substitute Text in Last Visual Area

Got this from VIM Wiki


:%s/\%Vold/new/g # Substitute Text in Last Visual Area
# Now imagine you'd selected a visual block with (Control V, or Control Q (Windows)) you could do a column based substitute!

gv # revisualise last visual area

Labels: , , ,


Wednesday, 24 June 2009

 

Vim: Including a register's contents in a substitute

"sub "fred" with contents of register "a" (Control R)
:s/fred/<c-r>a/g

or from the paste buffer

s/fred/<c-r>*/g

Here you actually do a Control-R.

It is often preferable to do use the following

:s/fred/\=@a/g : better alternative as register not displayed

unfortunately the \=@a must be at the beginning of replacement string

zzapper

Labels: ,


This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]