visual.txt For Vim version 9.1. Last change: 2025 Nov 09 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 {Since Vim 7.4.200 the |+visual| feature is always included} ============================================================================== 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 [count]v Start Visual mode per character. With [count] select the same number of characters or lines as used for the last Visual operation, but at the current cursor position, multiplied by [count]. When the previous Visual operation was on a block both the width and height of the block are multiplied by [count]. When there was no previous Visual operation [count] characters are selected. This is like moving the cursor right N * [count] characters. One less when 'selection' is not "exclusive". V linewise-visual [count]V Start Visual mode linewise. With [count] select the same number of lines as used for the last Visual operation, but at the current cursor position, multiplied by [count]. When there was no previous Visual operation [count] lines are selected. CTRL-V blockwise-visual [count]CTRL-V Start