visual

Rate this post
 *visual.txt* For Vim version 5.4. Last change: 1999 Jul 14 VIM REFERENCE MANUAL by Bram Moolenaar Visual mode *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. 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} ============================================================================== 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. Hit an operator. 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 highlighted text includes the character under the cursor. On terminals
where it is possible to make the cursor invisible the cursor position is
also highlighted. On terminals where this is not possible the cursor is
displayed normally. If your cursor cannot be made invisible and you want Vim
to highlight the character under the cursor anyway, you could set the 't_cv'
and 't_ci' options to something harmless, for example:
     :set t_cv=^[^[ t_ci=^[^[ 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
"~", 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 , 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*
gv Start Visual mode with the same area as the previous area and the same mode. In Visual mode the current and the previous Visual area are exchanged. **
 Set the current cursor position. If Visual mode is active it is stopped. Only when 'mouse' option is contains 'n' or 'a'. If the position is within 'so' lines from the last line on the screen the text is scrolled up. If the position is within 'so' lines from the first line on the screen the text is scrolled down. **
 Start Visual mode if it is not active. The text from the cursor position to the position of the click is highlighted. If Visual mode was already active move the start or end of the highlighted text, which ever is closest, to the position of the click. Only when 'mouse' option contains 'n' or 'a'. Note: when 'mousemodel' is set to "popup",  has to be used instead of . **
 This works like a , if it is not a the same position as . In an xterm you won't see the selected area until the button is released, unless there is access to the display where the xterm is running (via the DISPLAY environment variable or the -display argument). Only when 'mouse' option contains 'n' or 'a'. If Visual mode is not active and the "v", "V" or CTRL-V is preceded with a
count, the size of the previously highlighted area is used for a start. You
can then move the end of the highlighted area and give an operator. The type
of the old area is used (character, line or blockwise).
- Linewise Visual mode: The number of lines is multiplied with the count.
- Blockwise Visual mode: The number of lines and columns is multiplied with the count.
- Normal Visual mode within one line: The number of characters is multiplied with the count.
- Normal Visual mode with several lines: The number of lines is multiplied with the count, in the last line the same number of characters is used as in the last line in the previously highlighted area.
The start of the text is the Cursor position. If the "$" command was used as
one of the last commands to extend the highlighted text, the area will be
extended to the rightmost column of the longest line. If you want to highlight exactly the same area as the last time, you can use
"gv" |gv| |v_gv|. *v_CTRL-C*
CTRL-C In Visual mode: Stop Visual mode. When insert mode is pending (the mode message shows "-- (insert) VISUAL --"), it is also stopped. ============================================================================== 3. Changing the Visual area *visual-change* *v_o*
o Go to Other end of highlighted text: The current cursor position becomes the start of the highlighted text and the cursor is moved to the other end of the highlighted text. The highlighted area remains the same. *v_O*
O Go to Other end of highlighted text. This is like "o", but in Visual block mode the cursor moves to the other corner in the same line. When the corner is at a character that occupies more than one position on the screen (e.g., a ), the highlighted text may change. *v_$*
When the "$" command is used with blockwise Visual mode, the right end of the
highlighted text will be determined by the longest highlighted line. This
stops when a motion command is used that does not move straight up or down. For moving the end of the block many commands can be used, but you cannot
use Ex commands, commands that make changes or abandon the file. Commands
(starting with) ".pPiIaAO&", CTRL-^, "Z", CTRL-], CTRL-T, CTRL-R, CTRL-I
and CTRL-O cause a beep and Visual mode continues. ============================================================================== 4. Operating on the Visual area *visual-operators* The operators that can be used are: ~       switch case |v_~| d        delete |v_d| c    change (4) |v_c| y        yank |v_y| >    shift right (4) |v_>| <   shift left (4) |v_" (move lines 3 indents to the right). *{move-around}*
The {move-around} is any sequence of movement commands. Note the difference
with {motion}, which is only ONE movement command. ============================================================================== 5. Blockwise operators *blockwise-operators* {not available when compiled without the |+visualextra| feature} Visual-block Insert *v_b_I*
With a blockwise selection, Istring will insert string at the start of
block on every line of the block, provided that the line extends into the
block. TABs are split to retain visual columns.
See |v_b_I_example|. Visual-block Append *v_b_A*
With a blockwise selection, Astring will append string to the end of
block on every line of the block. There is some differing behavior where the
block RHS is not straight, due to different line lengths. a. Block was created with $ In this case the string is appended to the end of each line.
b. Block was created with {move-around} In this case the string is appended to the end of the block on each line which extends into the block, and whitespace is inserted to pad to the end-of-block column. Note: Padding is buggy (vim 5.4c).
See |v_b_A_example|. Visual-block change *v_b_c*
All selected text in the block will be replaced by the same text string. When
using "c" the selected text is deleted and Insert mode started. You can then
enter text (without a line break). When you hit , the same string is
inserted in all previously selected lines. Visual-block Change *v_b_C*
Like using "c", but the selection is extended until the end of the line for
all lines. *v_b_*
The block is shifted by 'shiftwidth'. The RHS of the block is irrelevant. The
LHS of the block determines the point from which to apply a right shift, and
padding includes TABs optimally according to 'ts' and 'et'. The LHS of the
block determines the point upto which to shift left. Note: v_< padding is buggy if the Visual Block starts and ends in the same TAB. (Vim 5.4c).
See |v_b_>_example|.
See |v_b_a` go to the end of the Visual area
a  break the line after the Visual area
`< jump to the start of the Visual area
i  break the line before the Visual area
!!date        filter the Visual text through date
kJJ Join the lines back together *visual-search*
Here is an idea for a mapping that makes it possible to do a search for the
selected text:
     :vmap X y/" (In the  notation ||, when typing it you should type it literally; you
need to remove the 'B' and '