Home Explore Blog CI



neovim

8th chunk of `runtime/doc/visual.txt`
43951fe154b5efbe0d56ff94a1037bd75e9d5c745b73f2a50000000100000d0e
 and <S-End>.  'keymodel'
  must also contain "startsel".
- Using "v", "V" or CTRL-V command, and 'selectmode' contains "cmd".
- Using "gh", "gH" or "g_CTRL-H" command in Normal mode.
- From Visual mode, press CTRL-G.			*v_CTRL-G*

Commands in Select mode:
- Printable characters, <NL> and <CR> cause the selection to be deleted, and
  Vim enters Insert mode.  The typed character is inserted.
- Non-printable movement commands, with the Shift key pressed, extend the
  selection.  'keymodel' must include "startsel".
- Non-printable movement commands, with the Shift key NOT pressed, stop Select
  mode.  'keymodel' must include "stopsel".
- ESC stops Select mode.
- 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.

Otherwise, typed characters are handled as in Visual mode.

When using an operator in Select mode, and the selection is linewise, the
selected lines are operated upon, but like in charwise selection.  For
example, when a whole line is deleted, it can later be pasted in the middle of
a line.


Mappings and menus in Select mode.			*Select-mode-mapping*

When mappings and menus are defined with the |:vmap| or |:vmenu| command they
work both in Visual mode and in Select mode.  When these are used in Select
mode Vim automatically switches to Visual mode, so that the same behavior as
in Visual mode is effective.  If you don't want this use |:xmap| or |:smap|.

One particular edge case: >
	: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>
<
Users will expect printable characters to replace the selected area.
Therefore avoid mapping printable characters in Select mode.  Or use
|:sunmap|  after |:map| and |:vmap| to remove it for Select mode.

After the mapping or menu finishes, the selection is enabled again and Select
mode entered, unless the selected area was deleted, another buffer became
the current one or the window layout was changed.

When a character was typed that causes the selection to be deleted and Insert
mode started, Insert mode mappings are applied to this character.  This may
cause some confusion, because it means Insert mode mappings apply to a
character typed in Select mode.  Language mappings apply as well.

							*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".

 vim:tw=78:ts=8:noet:ft=help:norl:

Title: Select Mode Details: Operators, Mappings, and Commands
Summary
This section elaborates on Select mode in Vim, covering how operators behave with linewise selections, and how mappings and menus defined for Visual mode also work in Select mode, with automatic switching to Visual mode. It discusses edge cases where mappings might not work as expected and suggests using specific mappings for Select mode. It also covers the impact of Insert mode mappings on characters typed in Select mode. Finally, it details the `gV` command to avoid automatic reselection after mappings, and introduces `gh`, `gH`, and `g_CTRL-H` to initiate Select mode charwise, linewise, and blockwise respectively, similar to `v`, `V`, and CTRL-V but starting in Select mode.