While using Vim, in visual mode, selecting text and then calling a colon command shows : '<,'>
instead of just :
as it would show when I do other things (such as opening a file).
What does '<,'>
mean?
Using linux (debian)
, gnome-terminal
, vim7.2
It means that the command that you type after :'<,'>
will operate on the part of the file that you've selected.
For example, :'<,'>d
would delete the selected block, whereas :d
deletes the line under the cursor.
Similarly, :'<,'>w fragment.txt
would write the selected block to the file called fragment.txt
.
The two comma-separated things ('<
and '>
) are marks that correspond to the start and the end of the selected area. From the help pages (:help '<
):
*'<* *`<*
'< `< To the first line or character of the last selected
Visual area in the current buffer. For block mode it
may also be the last character in the first line (to
be able to define the block). {not in Vi}.
*'>* *`>*
'> `> To the last line or character of the last selected
Visual area in the current buffer. For block mode it
may also be the first character of the last line (to
be able to define the block). Note that 'selection'
applies, the position may be just after the Visual
area. {not in Vi}.
When used in this manner, the marks simply specify the range for the command that follows (see :help range
). They can of course be mixed and matched with other line number specifiers. For example, the following command would delete all lines from the start of the selected area to the end of the file:
:'<,$d
The Vim Wiki has more information on Vim ranges.
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