Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Weird characters in GVim's visual mode

Tags:

vim

vi

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

like image 923
alexchenco Avatar asked Jan 21 '26 01:01

alexchenco


2 Answers

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.

like image 143
Caleb Hattingh Avatar answered Jan 23 '26 14:01

Caleb Hattingh


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.

like image 21
Alok Singhal Avatar answered Jan 23 '26 14:01

Alok Singhal