Help FAQ Both

Vim documentation: visual

main help file

*visual.txt*    For Vim version 7.3.  Last change: 2010 Feb 17


		  VIM REFERENCE MANUAL    by Bram Moolenaar



Visual mode				*Visual* *Visual-mode* *visual-mode*

Visual mode is a flexible and easy way to select a piece of text for an
operator.  It is the only way to select a block of text.

This is introduced in section |04.4| of the user manual.

1. Using Visual mode			|visual-use|
2. Starting and stopping Visual mode	|visual-start|
3. Changing the Visual area		|visual-change|
4. Operating on the Visual area		|visual-operators|
5. Blockwise operators			|blockwise-operators|
6. Repeating				|visual-repeat|
7. Examples				|visual-examples|
8. Select mode				|Select-mode|

{Vi has no Visual mode, the name "visual" is used for Normal mode, to
distinguish it from Ex mode}
{not available when the |+visual| feature was disabled when compiling}

==============================================================================

1. Using Visual mode					*visual-use*

Using Visual mode consists of three parts:
1. Mark the start of the text with "v", "V" or CTRL-V.
   The character under the cursor will be used as the start.
2. Move to the end of the text.
   The text from the start of the Visual mode up to and including the
   character under the cursor is highlighted.
3. Type an operator command.
   The highlighted characters will be operated upon.

The 'highlight' option can be used to set the display mode to use for
highlighting in Visual mode.
The 'virtualedit' option can be used to allow positioning the cursor to
positions where there is no actual character.

The highlighted text normally includes the character under the cursor.
However, when the 'selection' option is set to "exclusive" and the cursor is
after the Visual area, the character under the cursor is not included.

With "v" the text before the start position and after the end position will
not be highlighted.  However, all uppercase and non-alpha operators, except
"~" and "U", will work on whole lines anyway.  See the list of operators
below.


							*visual-block*
With CTRL-V (blockwise Visual mode) the highlighted text will be a rectangle
between start position and the cursor.  However, some operators work on whole
lines anyway (see the list below).  The change and substitute operators will
delete the highlighted text and then start insertion at the top left
position.

==============================================================================

2. Starting and stopping Visual mode			*visual-start*


						*v* *characterwise-visual*
v			start Visual mode per character.


						*V* *linewise-visual*
V			start Visual mode linewise.


						*CTRL-V* *blockwise-visual*
CTRL-V			start Visual mode blockwise.  Note: Under Windows
			CTRL-V could be mapped to paste text, it doesn't work
			to start Visual mode then, see |CTRL-V-alternative|.

If you use <Esc>, click the left mouse button or use any command that
does a jump to another buffer while in Visual mode, the highlighting stops
and no text is affected.  Also when you hit "v" in characterwise Visual mode,
"CTRL-V" in blockwise Visual mode or "V" in linewise Visual mode.  If you hit
CTRL-Z the highlighting stops and the editor is suspended or a new shell is
started |CTRL-Z|.


	      new mode after typing:		*v_v* *v_CTRL-V* *v_V*
old mode	     "v"	      "CTRL-V"		     "V"	

Normal		    Visual	   blockwise Visual	  linewise Visual
Visual		    Normal	   blockwise Visual	  linewise Visual
blockwise Visual    Visual	   Normal		  linewise Visual
linewise Visual     Visual	   blockwise Visual	  Normal


						*gv* *v_gv* *reselect-Visual*
gv			Start Visual mode with the same area as the previous
			area and the same mode.
			In Visual mode the current and the previous