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
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
This is of course not a bug. It is the range modifier that can precede commands, in this case it means the visually highlighted range.
Type
:h cmdline-ranges
to learn more about ranges.
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.
'<,'>
is your visually selected area. Think about it, its easy to represent ranges if you know numbers, but for a visually selected text the only way to represent them (write/type it down) would be to use specialized symbols, and in this case '<,'>
What more, you can do commands on the visually selected area the same way you'd do commands over a range of line numbers
1,200 s/old/new/c
'<,'> s/old/new/c