A little about the selection mode for those who are too lazy to go through the vimtutor, or those who still doubt that Vim is really convenient.
The selection mode in Vim is one of those great things (along with
* ,
= and
text-objects ) that make this editor especially convenient. As you already know, Vim has a Visual mode in which you can select text so that you can do something with the selection, for example, stick it into a register, format it, replace it with a regular expression, or something else. To enter this mode, you need to press
v , and then move the cursor with the usual commands that move the cursor in the normal mode, thus expanding the selection area.
There are several selection modes: regular, progressive and block. Normal is turned on with the
v command and highlights text from character to character. Progressive is activated with the
V command (
Shift + v ) and selects the entire line. Block is activated with the command
Ctrl + V (under Windows,
Ctrl + Q can be turned on if
Ctrl + V is occupied by pasting text from the clipboard) selects a vertical block of text (does not capture the beginnings and the ends of lines in the middle of the selection, as it normally does).
')
And now, a little bit special, Vim's magic. Suppose you started to select text, but noticed that the beginning of the selection is not where you wanted. In most editors you will need to reset the selection and select the text again. In Vim, you can press
o and expand the selection in the other direction. If you are in block mode,
o will move the cursor across the block diagonally, that is, for example, from the upper left corner of the block to the lower right. If you want to change the selection using the remaining two corners, press
O (
Shift + o ).
But that is not all. Imagine that you started to select in the normal mode, but then decided that you had to do it in line by line. Just press
V , the selection mode will change to line by line and you will not lose the current selection. You can change the modes as you like without resetting the selection, and it seems to me that this is really very convenient. And lastly, if you need to select the same piece of text that you had selected the last time (for example, you accidentally dropped a selection, or did something to it and want to do something else) - just press
gv .