refactor!: delete insertmode (#18547)

Neovim already removed `evim` (or any similar flags). The 'insertmode'
option is a weird remnant, so get rid of it.

The 'insertmode' option is replaced with a script that closely emulates
the option. This script is documented at :help 'insertmode'
This commit is contained in:
Gregory Anders
2022-05-22 21:20:18 -06:00
committed by GitHub
parent a7e0a02031
commit 9e1ee9fb1d
29 changed files with 62 additions and 270 deletions

View File

@@ -1065,8 +1065,7 @@ line contains the command as typed so far. The left column will show a
character that indicates the type of command-line being edited, see
|cmdwin-char|.
Vim will be in Normal mode when the editor is opened, except when 'insertmode'
is set.
Vim will be in Normal mode when the editor is opened.
The height of the window is specified with 'cmdwinheight' (or smaller if there
is no room). The window is always full width and is positioned just above the

View File

@@ -1366,7 +1366,7 @@ option *expr-option* *E112* *E113*
Examples: >
echo "tabstop is " .. &tabstop
if &insertmode
if &expandtab
Any option name can be used here. See |options|. When using the local value
and there is no buffer-local or window-local value, the global value is used

View File

@@ -224,9 +224,6 @@ some modes:
Cmdline <C-C> <C-\><C-G>
Op-pending <C-C> <C-\><C-G>
Appending CTRL-\ CTRL-G is for going back to insert mode when 'insertmode' is
set. |CTRL-\_CTRL-G|
Example: >
:amenu File.Next :next^M

View File

@@ -26,7 +26,7 @@ tag char action in Insert mode ~
insert
|i_CTRL-A| CTRL-A insert previously inserted text
|i_CTRL-C| CTRL-C quit insert mode, without checking for
abbreviation, unless 'insertmode' set.
abbreviation
|i_CTRL-D| CTRL-D delete one shiftwidth of indent in the current
line
|i_CTRL-E| CTRL-E insert the character which is below the cursor
@@ -50,7 +50,6 @@ tag char action in Insert mode ~
|i_CTRL-J| CTRL-J same as <CR>
|i_CTRL-K| CTRL-K {char1} {char2}
enter digraph
|i_CTRL-L| CTRL-L when 'insertmode' set: Leave Insert mode
|i_<CR>| <CR> begin new line
|i_CTRL-M| CTRL-M same as <CR>
|i_CTRL-N| CTRL-N find next match for keyword in front of the
@@ -86,11 +85,10 @@ tag char action in Insert mode ~
|i_CTRL-W| CTRL-W delete word before the cursor
|i_CTRL-X| CTRL-X {mode} enter CTRL-X sub mode, see |i_CTRL-X_index|
|i_CTRL-Y| CTRL-Y insert the character which is above the cursor
|i_CTRL-Z| CTRL-Z when 'insertmode' set: suspend Vim
|i_<Esc>| <Esc> end insert mode (unless 'insertmode' set)
|i_<Esc>| <Esc> end insert mode
|i_CTRL-[| CTRL-[ same as <Esc>
|i_CTRL-\_CTRL-N| CTRL-\ CTRL-N go to Normal mode
|i_CTRL-\_CTRL-G| CTRL-\ CTRL-G go to mode specified with 'insertmode'
|i_CTRL-\_CTRL-G| CTRL-\ CTRL-G go to Normal mode
CTRL-\ a - z reserved for extensions
CTRL-\ others not used
|i_CTRL-]| CTRL-] trigger abbreviation
@@ -221,7 +219,7 @@ tag char note action in Normal mode ~
|CTRL-Z| CTRL-Z suspend program (or start new shell)
CTRL-[ <Esc> not used
|CTRL-\_CTRL-N| CTRL-\ CTRL-N go to Normal mode (no-op)
|CTRL-\_CTRL-G| CTRL-\ CTRL-G go to mode specified with 'insertmode'
|CTRL-\_CTRL-G| CTRL-\ CTRL-G go to Normal mode (no-op)
CTRL-\ a - z reserved for extensions
CTRL-\ others not used
|CTRL-]| CTRL-] :ta to ident under cursor
@@ -892,7 +890,7 @@ here are those that are different.
tag command note action in Visual mode ~
------------------------------------------------------------------------------
|v_CTRL-\_CTRL-N| CTRL-\ CTRL-N stop Visual mode
|v_CTRL-\_CTRL-G| CTRL-\ CTRL-G go to mode specified with 'insertmode'
|v_CTRL-\_CTRL-G| CTRL-\ CTRL-G go to Normal mode
|v_CTRL-A| CTRL-A 2 add N to number in highlighted text
|v_CTRL-C| CTRL-C stop Visual mode
|v_CTRL-G| CTRL-G toggle between Visual mode and Select mode
@@ -1068,8 +1066,7 @@ tag command action in Command-line editing mode ~
|c_<Esc>| <Esc> abandon command-line without executing it
|c_CTRL-[| CTRL-[ same as <Esc>
|c_CTRL-\_CTRL-N| CTRL-\ CTRL-N go to Normal mode, abandon command-line
|c_CTRL-\_CTRL-G| CTRL-\ CTRL-G go to mode specified with 'insertmode',
abandon command-line
|c_CTRL-\_CTRL-G| CTRL-\ CTRL-G go to Normal mode, abandon command-line
CTRL-\ a - d reserved for extensions
|c_CTRL-\_e| CTRL-\ e {expr} replace the command line with the result of
{expr}

View File

@@ -32,9 +32,6 @@ If you are working in a special language mode when inserting text, see the
'langmap' option, |'langmap'|, on how to avoid switching this mode on and off
all the time.
If you have 'insertmode' set, <Esc> and a few other keys get another meaning.
See |'insertmode'|.
char action ~
-----------------------------------------------------------------------
*i_CTRL-[* *i_<Esc>*
@@ -335,9 +332,8 @@ that key is interpreted as in Insert mode.
The following keys are special. They stop the current insert, do something,
and then restart insertion. This means you can do something without getting
out of Insert mode. This is very handy if you prefer to use the Insert mode
all the time, just like editors that don't have a separate Normal mode. You
may also want to set the 'insertmode' option. You can use CTRL-O if you want
to map a function key to a command.
all the time, just like editors that don't have a separate Normal mode. You
can use CTRL-O if you want to map a function key to a command.
The changes (inserted or deleted characters) before and after these keys can
be undone separately. Only the last change can be redone and always behaves
@@ -378,7 +374,6 @@ CTRL-G CTRL-J cursor one line down, insert start column *i_CTRL-G_CTRL-J*
<S-ScrollWheelRight> move window one page right *i_<S-ScrollWheelRight>*
CTRL-O execute one command, return to Insert mode *i_CTRL-O*
CTRL-\ CTRL-O like CTRL-O but don't move the cursor *i_CTRL-\_CTRL-O*
CTRL-L when 'insertmode' is set: go to Normal mode *i_CTRL-L*
CTRL-G u break undo sequence, start new change *i_CTRL-G_u*
CTRL-G U don't break undo with next left/right cursor *i_CTRL-G_U*
movement, if the cursor stays within the

View File

@@ -424,8 +424,7 @@ Vim has seven BASIC modes:
*Normal* *Normal-mode* *command-mode*
Normal mode In Normal mode you can enter all the normal editor
commands. If you start the editor you are in this
mode (unless you have set the 'insertmode' option,
see below). This is also known as command mode.
mode. This is also known as command mode.
Visual mode This is like Normal mode, but the movement commands
extend a highlighted area. When a non-movement
@@ -551,8 +550,6 @@ Ex :vi -- -- -- -- --
*6 Go from Select mode to Insert mode by typing a printable character. The
selection is deleted and the character is inserted.
If the 'insertmode' option is on, editing a file will start in Insert mode.
*CTRL-\_CTRL-N* *i_CTRL-\_CTRL-N* *c_CTRL-\_CTRL-N* *v_CTRL-\_CTRL-N*
Additionally the command CTRL-\ CTRL-N or <C-\><C-N> can be used to go to
Normal mode from any other mode. This can be used to make sure Vim is in
@@ -561,10 +558,7 @@ work in Ex mode. When used after a command that takes an argument, such as
|f| or |m|, the timeout set with 'ttimeoutlen' applies.
*CTRL-\_CTRL-G* *i_CTRL-\_CTRL-G* *c_CTRL-\_CTRL-G* *v_CTRL-\_CTRL-G*
The command CTRL-\ CTRL-G or <C-\><C-G> can be used to go to Insert mode when
'insertmode' is set. Otherwise it goes to Normal mode. This can be used to
make sure Vim is in the mode indicated by 'insertmode', without knowing in
what mode Vim currently is.
CTRL-\ CTRL-G works the same as |CTRL-\_CTRL-N| for backward compatibility.
*gQ* *mode-Ex* *Ex-mode* *Ex* *EX* *E501*
gQ Switch to Ex mode. This is like typing ":" commands

View File

@@ -959,7 +959,6 @@ A jump table for the options with a short description can be found at |Q_op|.
(mostly used in |Normal-mode| or |Cmdline-mode|).
esc hitting <Esc> in |Normal-mode|.
hangul Ignored.
insertmode Pressing <Esc> in 'insertmode'.
lang Calling the beep module for Lua/Mzscheme/TCL.
mess No output available for |g<|.
showmatch Error occurred for 'showmatch' function.
@@ -3412,31 +3411,6 @@ A jump table for the options with a short description can be found at |Q_op|.
and there is a letter before it, the completed part is made uppercase.
With 'noinfercase' the match is used as-is.
*'insertmode'* *'im'* *'noinsertmode'* *'noim'*
'insertmode' 'im' boolean (default off)
global
Makes Vim work in a way that Insert mode is the default mode. Useful
if you want to use Vim as a modeless editor.
These Insert mode commands will be useful:
- Use the cursor keys to move around.
- Use CTRL-O to execute one Normal mode command |i_CTRL-O|. When
this is a mapping, it is executed as if 'insertmode' was off.
Normal mode remains active until the mapping is finished.
- Use CTRL-L to execute a number of Normal mode commands, then use
<Esc> to get back to Insert mode. Note that CTRL-L moves the cursor
left, like <Esc> does when 'insertmode' isn't set. |i_CTRL-L|
These items change when 'insertmode' is set:
- when starting to edit of a file, Vim goes to Insert mode.
- <Esc> in Insert mode is a no-op and beeps.
- <Esc> in Normal mode makes Vim go to Insert mode.
- CTRL-L in Insert mode is a command, it is not inserted.
- CTRL-Z in Insert mode suspends Vim, see |CTRL-Z|. *i_CTRL-Z*
However, when <Esc> is used inside a mapping, it behaves like
'insertmode' was not set. This was done to be able to use the same
mappings with 'insertmode' set or not set.
When executing commands with |:normal| 'insertmode' is not used.
*'isfname'* *'isf'*
'isfname' 'isf' string (default for Windows:
"@,48-57,/,\,.,-,_,+,,,#,$,%,{,},[,],:,@-@,!,~,="

View File

@@ -741,7 +741,6 @@ Short explanation of each option: *option-list*
'indentexpr' 'inde' expression used to obtain the indent of a line
'indentkeys' 'indk' keys that trigger indenting with 'indentexpr'
'infercase' 'inf' adjust case of match for keyword completion
'insertmode' 'im' start the edit of a file in Insert mode
'isfname' 'isf' characters included in file names and pathnames
'isident' 'isi' characters included in identifiers
'iskeyword' 'isk' characters included in keywords

View File

@@ -527,7 +527,6 @@ accordingly, proceeding as follows:
16. Execute startup commands
If a |-t| flag was given, the tag is jumped to.
Commands given with |-c| and |+cmd| are executed.
If the 'insertmode' option is set, Insert mode is entered.
The starting flag is reset, has("vim_starting") will now return zero.
The |v:vim_did_enter| variable is set to 1.
The |VimEnter| autocommands are executed.

View File

@@ -208,8 +208,6 @@ g8 Print the hex values of the bytes used in the
{commands} cannot start with a space. Put a count of
1 (one) before it, "1 " is one space.
The 'insertmode' option is ignored for {commands}.
This command cannot be followed by another command,
since any '|' is considered part of the command.

View File

@@ -543,6 +543,13 @@ Options:
*'imactivatefunc'* *'imaf'*
*'imactivatekey'* *'imak'*
*'imstatusfunc'* *'imsf'*
*'insertmode'* *'im'* Use the following script to emulate 'insertmode':
>
autocmd VimEnter,CmdlineLeave,WinEnter,WinScrolled,BufEnter * silent! if &modifiable | startinsert | endif
inoremap <Esc> <Nop>
inoremap <C-L> <Esc>
nnoremap <Esc> i
<
*'macatsui'*
'maxmem' Nvim delegates memory-management to the OS.
'maxmemtot' Nvim delegates memory-management to the OS.

View File

@@ -229,8 +229,6 @@ call append("$", "compatible\tbehave very Vi compatible (not advisable)")
call <SID>BinOptionG("cp", &cp)
call append("$", "cpoptions\tlist of flags to specify Vi compatibility")
call <SID>OptionG("cpo", &cpo)
call append("$", "insertmode\tuse Insert mode as the default mode")
call <SID>BinOptionG("im", &im)
call append("$", "paste\tpaste mode, insert typed text literally")
call <SID>BinOptionG("paste", &paste)
call append("$", "pastetoggle\tkey sequence to toggle paste mode")