Nvim :help
pages, generated
from source
using the tree-sitter-vimdoc parser.
Visual-mode
visual-mode
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.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.v
charwise-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 Visual mode blockwise.<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 charwise 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.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 Visual
area are exchanged.
After using "p" or "P" in Visual mode the text that
was put will be selected.gn
v_gn
gn Search forward for the last used search pattern, like
with n
, and start Visual mode to select the match.
If the cursor is on the match, visually selects it.
If an operator is pending, operates on the match.
E.g., "dgn" deletes the text of the next match.
If Visual mode is active, extends the selection
until the end of the next match.
'wrapscan' applies.
Note: Unlike n
the search direction does not depend
on the previous search command.<LeftMouse>
<LeftMouse>
Set the current cursor position. If Visual mode is
active it is stopped. Only when 'mouse' option
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.<RightMouse>
<RightMouse>
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, whichever
is closest, to the position of the click. Only when
'mouse' option contains 'n' or 'a'.<LeftRelease>
<LeftRelease>
This works like a <LeftMouse>
, if it is not at
the same position as <LeftMouse>
. In an older version
of 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'.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).
v_<Esc>
<Esc>
In Visual mode: Stop Visual mode.
v_META
v_ALT
ALT (META) may act like <Esc>
if the chord is not mapped.
For example <A-x>
acts like <Esc>
x if <A-x>
does not have a
visual-mode mapping.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.
On MS-Windows, you may need to press CTRL-Break
.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 <Tab>
), 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.CTRL-^
, "Z", CTRL-]
, CTRL-T
, CTRL-R
, CTRL-I
and CTRL-O
cause a beep and Visual mode continues.<RightMouse>
(or <S-LeftMouse>
when
'mousemodel' is "popup") to drag either end of the Visual area.<tag>
</tag> block (with tags) v_at
it inner <tag>
</tag> block v_it
a< a <> block (with <>) v_a<
i< inner <> block v_i<
a[ a [] block (with []) v_a[
i[ inner [] block v_i[
a" a double quoted string (with quotes) v_aquote
i" inner double quoted string v_iquote
a' a single quoted string (with quotes) v_a'
i' inner simple quoted string v_i'
a` a string in backticks (with backticks) v_a`
i` inner string in backticks v_i`CTRL-V
.
(3): Whole lines when not using CTRL-V
, delete until the end of the line when
using CTRL-V
.
(4): When using CTRL-V
operates on the block only.:vmap / y/<C-R>"<CR>(In the <> notation <>, when typing it you should type it literally; you need to remove the 'B' flag from 'cpoptions'.)
{move-around}
The {move-around}
is any sequence of movement commands. Note the difference
with {motion}
, which is only ONE movement command.:'<,'>s/\%V(/#/gNote that the "'<,'>" will appear automatically when you press ":" in Visual mode.
v_b_I
With a blockwise selection, I{string}<ESC> will insert {string}
at the start
of block on every line of the block, provided that the line extends into the
block. Thus lines that are short will remain unmodified. TABs are split to
retain visual columns. Works only for adding text to a line, not for
deletions. See v_b_I_example.v_b_A
With a blockwise selection, A{string}<ESC> 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:<C-v>
$
In this case the string is appended to the end of each line.
2. Block was created with <C-v>
{move-around}
In this case the string is appended to the end of the block on each line,
and whitespace is inserted to pad to the end-of-block column.
See v_b_A_example.
Note: "I" and "A" behave differently for lines that don't extend into the
selected block. This was done intentionally, so that you can do it the way
you want.
Works only for adding text to a line, not for deletions.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 <Esc>
, the same string is
inserted in all previously selected lines.v_b_C
Like using "c", but the selection is extended until the end of the line for
all lines.v_b_<
Visual-block Shift 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 up to which to shift left.
See v_b_>_example.
See v_b_<_example.v_b_r
Every screen char in the highlighted region is replaced with the same char, ie
TABs are split and the virtual whitespace is replaced, maintaining screen
layout.
See v_b_r_example..
command is not used.
:visual_example
Currently the ":" command works on whole lines only. When you select part of
a line, doing something like ":!date" will replace the whole line. If you
want only part of the line to be replaced you will have to make a mapping for
it. In a future release ":" may work on partial lines.:vmap _a <Esc>`>a<CR><Esc>`<i<CR><Esc>!!date<CR>kJJ(In the <> notation <>, when typing it you should type it literally; you need to remove the 'B' flag from 'cpoptions')
<Esc>
stop Visual mode
> go to the end of the Visual area
a<CR><Esc> break the line after the Visual area
< jump to the start of the Visual area
i<CR><Esc> break the line before the Visual area
!!date<CR> filter the Visual text through date
kJJ Join the lines back togethervisual-search
Here is an idea for a mapping that makes it possible to do a search for the
selected text::vmap X y/<C-R>"<CR>(In the <> notation <>, when typing it you should type it literally; you need to remove the 'B' flag from 'cpoptions')
blockwise-examples
With the following text, I will indicate the commands to produce the block and
the results below. In all cases, the cursor begins on the 'a' in the first
line of the test text.
The following modeline settings are assumed ":ts=8:sw=4:".<TAB>
is a real TAB. This helps visualise the operations.v_b_I_example
v_b_A_example
v_b_<_example
v_b_>_example
v_b_r_example
<S-Left>
and <S-End>
. 'keymodel'
must also contain "startsel".
CTRL-V
command, and 'selectmode' contains "cmd".
CTRL-G
. v_CTRL-G
<NL>
and <CR>
cause the selection to be deleted, and
Vim enters Insert mode. The typed character is inserted.
CTRL-O
switches to Visual mode for the duration of one command. v_CTRL-O
CTRL-G
switches to Visual mode.
CTRL-R
{register}
selects the register to be used for the text that is
deleted when typing text. v_CTRL-R
Unless you specify the "_" (black hole) register, the unnamed register is
also overwritten.
Select-mode-mapping
:vnoremap <C-K> <Esc>This ends Visual mode when in Visual mode, but in Select mode it does not work, because Select mode is restored after executing the mapped keys. You need to use:
:snoremap <C-K> <Esc>
gV
v_gV
gV Avoid the automatic reselection of the Visual area
after a Select mode mapping or menu has finished.
Put this just before the end of the mapping or menu.
At least it should be after any operations on the
selection.gh
gh Start Select mode, charwise. This is like "v",
but starts Select mode instead of Visual mode.
Mnemonic: "get highlighted".gH
gH Start Select mode, linewise. This is like "V",
but starts Select mode instead of Visual mode.
Mnemonic: "get Highlighted".g_CTRL-H
g CTRL-H
Start Select mode, blockwise. This is like CTRL-V
,
but starts Select mode instead of Visual mode.
Mnemonic: "get Highlighted".