sponsor Vim development Vim logo Vim Book Ad

intermediate Tip #429: Using '< and '> marks

 tip karma   Rating 20/11, Viewed by 2707 

Read and edit this tip on the Vim tip wiki. The wiki may have a more recent version of this tip.

created:   February 18, 2003 4:50      complexity:   intermediate
author:   Max Ischenko      as of Vim:   5.7


Today I discovered that '< and '> persists even after the selection is gone.
Thus, to repeat an Ex command over a previously selected (via V command) block
just use : history -- no need to reselect block again.

 rate this tip  Life Changing Helpful Unfulfilling 

<< Wordwise Ctrl-Y in insert mode | Fast switching between buffers >>

Additional Notes

cec@NgrOyphSon.gPsfAc.nMasa.gov, February 20, 2003 8:18
gv is even easier!
Max Ischenko, February 21, 2003 6:04
> gv is even easier.
To repeat an Ex command (like :s) you don't have to reselect block at all, so gv is not needed.
That's the point of this tip.
yeti@physics.muni.cz, February 21, 2003 9:52
Most people can type gv: much faster than :'<,'> (just try it :-)

Moreover, gv makes the selection visible. (Yes, I know, it's very non-vi to have a visual feedback for what you are doing ;-)
Max Ischenko, February 24, 2003 1:20

> Most people can type gv: much faster than :'<,'>

I bet typing :<Up> still faster then gv:<Up>.
rickismyid@yahoo.com, March 5, 2003 5:09
I think just pressing the period will work too. Unless I'm missunderstanding what is being done.
jaldri1 at gl dot umbc dot edu, June 6, 2003 12:47
So, I can start a visual block  with <c-v> (win: <c-q> |CTRL-V-alternative|) at the start of some columen and select some text with, say, 4j$.   Now I have a highlighted selection.   I can press y to yank.  If I press :, ex mode starts with :'<,'> already filled in.  If I press !, I get :'<,'>!.  Unfortunately, if I enter an external command such as sort, it operates on the whole lines (^.*$) not just the column of the visual block.  

Anyway, I can yank and move elsewhere, paste, and then return to the original selection with gv (not :gv).  And, that selection will be highlighted just as before.   I can also use '< to move to the first line of the selection or '> to move to the last line of the selection.

Have I explained it well enough, or was there more intended?
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 vim@vim.org after searching the archive. Help Bram help Uganda.
   
Sponsored by Web Concept Group Inc. SourceForge.net Logo