3

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

2
  • DO I have to write the operation after those characters or inside those characters? for instance the Align plugin, requires me to write: :Align =
    – wyc
    Jan 13, 2010 at 12:41
  • just type after them. it's the same kind of modifier as % Jan 13, 2010 at 18:29

5 Answers 5

7

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.

2

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.

1

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.

0

they're normal indication of a range.

0

'<,'> 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.