When I enter visual mode (from normal mode), and when then I press : there are these characters: <,'> after the :
They are a feature or a bug?
Windows XP SP2
alt text http://img94.imageshack.us/img94/5590/16595366.jpg
You have a visual range selected, and when you enter : while that is the case, then the selected range specifier '<,'> is automatically added to indicate that the command will only be applied to the selection.
In vi[m], you can apply : commands (ex-commands) on the current line (default), or any other line, or more generally, a range of lines. The range is denoted as start,end. For example, do delete the current line, you can do:
:d
To delete three lines in the range (current-1) to (current+1):
:-1,+1d
In vim, marks < and > are used to denote the current selection (or the last selection if nothing is selected). So, when you type a : in visual mode, vim is smart enough to realize that you might want to apply the command only to the selected region, so gives you the range after the :. You just type your command and the results apply only to the selection. (Well, the range defined by lines in the selection, to be precise.)
That means that you can actually move to the lines containing the beginning and the end of the last selected region by typing '< and '> respectively. Replace ' with ` (backtick) to the beginning/end of the selection.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With