diff options
author | Gregory Anders <8965202+gpanders@users.noreply.github.com> | 2022-05-22 21:20:18 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-22 21:20:18 -0600 |
commit | 9e1ee9fb1d747facb6fa97a32dc5e22c7dfcb346 (patch) | |
tree | b6fe628698f9d4181285a144b17b7518833693ce | |
parent | a7e0a02031c7b4a192cb9c0e4eb13a714d5b0dbb (diff) | |
download | rneovim-9e1ee9fb1d747facb6fa97a32dc5e22c7dfcb346.tar.gz rneovim-9e1ee9fb1d747facb6fa97a32dc5e22c7dfcb346.tar.bz2 rneovim-9e1ee9fb1d747facb6fa97a32dc5e22c7dfcb346.zip |
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'
-rw-r--r-- | runtime/doc/cmdline.txt | 3 | ||||
-rw-r--r-- | runtime/doc/eval.txt | 2 | ||||
-rw-r--r-- | runtime/doc/gui.txt | 3 | ||||
-rw-r--r-- | runtime/doc/index.txt | 15 | ||||
-rw-r--r-- | runtime/doc/insert.txt | 9 | ||||
-rw-r--r-- | runtime/doc/intro.txt | 10 | ||||
-rw-r--r-- | runtime/doc/options.txt | 26 | ||||
-rw-r--r-- | runtime/doc/quickref.txt | 1 | ||||
-rw-r--r-- | runtime/doc/starting.txt | 1 | ||||
-rw-r--r-- | runtime/doc/various.txt | 2 | ||||
-rw-r--r-- | runtime/doc/vim_diff.txt | 7 | ||||
-rw-r--r-- | runtime/optwin.vim | 2 | ||||
-rw-r--r-- | src/nvim/edit.c | 60 | ||||
-rw-r--r-- | src/nvim/ex_cmds.c | 9 | ||||
-rw-r--r-- | src/nvim/ex_docmd.c | 3 | ||||
-rw-r--r-- | src/nvim/ex_docmd.h | 1 | ||||
-rw-r--r-- | src/nvim/ex_getln.c | 6 | ||||
-rw-r--r-- | src/nvim/getchar.c | 9 | ||||
-rw-r--r-- | src/nvim/main.c | 5 | ||||
-rw-r--r-- | src/nvim/normal.c | 45 | ||||
-rw-r--r-- | src/nvim/ops.c | 2 | ||||
-rw-r--r-- | src/nvim/option.c | 15 | ||||
-rw-r--r-- | src/nvim/option_defs.h | 7 | ||||
-rw-r--r-- | src/nvim/options.lua | 4 | ||||
-rw-r--r-- | src/nvim/quickfix.c | 4 | ||||
-rw-r--r-- | src/nvim/testdir/test_edit.vim | 23 | ||||
-rw-r--r-- | src/nvim/testdir/test_normal.vim | 9 | ||||
-rw-r--r-- | test/functional/editor/mode_insert_spec.lua | 24 | ||||
-rw-r--r-- | test/functional/legacy/edit_spec.lua | 25 |
29 files changed, 62 insertions, 270 deletions
diff --git a/runtime/doc/cmdline.txt b/runtime/doc/cmdline.txt index 6228c9238f..23a87505ad 100644 --- a/runtime/doc/cmdline.txt +++ b/runtime/doc/cmdline.txt @@ -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 diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index d1686741b4..71f5ad4536 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -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 diff --git a/runtime/doc/gui.txt b/runtime/doc/gui.txt index 812259741f..e296141c39 100644 --- a/runtime/doc/gui.txt +++ b/runtime/doc/gui.txt @@ -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 diff --git a/runtime/doc/index.txt b/runtime/doc/index.txt index 58d49b5843..ee8a820e53 100644 --- a/runtime/doc/index.txt +++ b/runtime/doc/index.txt @@ -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} diff --git a/runtime/doc/insert.txt b/runtime/doc/insert.txt index 7f6662089d..3c5d246a49 100644 --- a/runtime/doc/insert.txt +++ b/runtime/doc/insert.txt @@ -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 diff --git a/runtime/doc/intro.txt b/runtime/doc/intro.txt index 4e3dcf850c..0074dc0733 100644 --- a/runtime/doc/intro.txt +++ b/runtime/doc/intro.txt @@ -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 diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 0c2de7d6ee..9015f0a97e 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -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,/,\,.,-,_,+,,,#,$,%,{,},[,],:,@-@,!,~,=" diff --git a/runtime/doc/quickref.txt b/runtime/doc/quickref.txt index ff7e2ab400..1716ea025d 100644 --- a/runtime/doc/quickref.txt +++ b/runtime/doc/quickref.txt @@ -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 diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index f542f33451..8b88fa9363 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -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. diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt index 0a25904104..562faeaa2c 100644 --- a/runtime/doc/various.txt +++ b/runtime/doc/various.txt @@ -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. diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index c926337b47..85b44e3b51 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -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. diff --git a/runtime/optwin.vim b/runtime/optwin.vim index 493f7b57d0..54f57a260c 100644 --- a/runtime/optwin.vim +++ b/runtime/optwin.vim @@ -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") diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 593a358b62..1cc60f9953 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -459,9 +459,8 @@ static void insert_enter(InsertState *s) where_paste_started.lnum = 0; can_cindent = true; - // The cursor line is not in a closed fold, unless 'insertmode' is set or - // restarting. - if (!p_im && did_restart_edit == 0) { + // The cursor line is not in a closed fold, unless restarting. + if (did_restart_edit == 0) { foldOpenCursor(); } @@ -473,7 +472,7 @@ static void insert_enter(InsertState *s) s->i = showmode(); } - if (!p_im && did_restart_edit == 0) { + if (did_restart_edit == 0) { change_warning(curbuf, s->i == 0 ? 0 : s->i + 1); } @@ -554,7 +553,7 @@ static int insert_check(VimState *state) } if (stop_insert_mode && !compl_started) { - // ":stopinsert" used or 'insertmode' reset + // ":stopinsert" used s->count = 0; return 0; // exit insert mode } @@ -756,7 +755,6 @@ static int insert_execute(VimState *state, int key) } // CTRL-\ CTRL-N goes to Normal mode, - // CTRL-\ CTRL-G goes to mode selected with 'insertmode', // CTRL-\ CTRL-O is like CTRL-O but without moving the cursor if (s->c == Ctrl_BSL) { // may need to redraw when no more chars available now @@ -770,8 +768,6 @@ static int insert_execute(VimState *state, int key) // it's something else vungetc(s->c); s->c = Ctrl_BSL; - } else if (s->c == Ctrl_G && p_im) { - return 1; // continue } else { if (s->c == Ctrl_O) { ins_ctrl_o(); @@ -843,16 +839,6 @@ static int insert_execute(VimState *state, int key) } -/// Return true when need to go to Insert mode because of 'insertmode'. -/// -/// Don't do this when still processing a command or a mapping. -/// Don't do this when inside a ":normal" command. -bool goto_im(void) - FUNC_ATTR_PURE -{ - return p_im && stuff_empty() && typebuf_typed(); -} - static int insert_handle_key(InsertState *s) { // The big switch to handle a character in insert mode. @@ -884,26 +870,10 @@ static int insert_handle_key(InsertState *s) } } - // when 'insertmode' set, and not halfway through a mapping, don't leave - // Insert mode - if (goto_im()) { - if (got_int) { - (void)vgetc(); // flush all buffers - got_int = false; - } else { - vim_beep(BO_IM); - } - break; - } return 0; // exit insert mode - case Ctrl_Z: // suspend when 'insertmode' set - if (!p_im) { - goto normalchar; // insert CTRL-Z as normal char - } - do_cmdline_cmd("stop"); - ui_cursor_shape(); // may need to update cursor shape - break; + case Ctrl_Z: + goto normalchar; // insert CTRL-Z as normal char case Ctrl_O: // execute one command if (ctrl_x_mode == CTRL_X_OMNI) { @@ -939,9 +909,6 @@ static int insert_handle_key(InsertState *s) case K_F1: case K_XF1: stuffcharReadbuff(K_HELP); - if (p_im) { - need_start_insertmode = true; - } return 0; // exit insert mode @@ -956,7 +923,7 @@ static int insert_handle_key(InsertState *s) // For ^@ the trailing ESC will end the insert, unless there is an // error. if (stuff_inserted(NUL, 1L, (s->c == Ctrl_A)) == FAIL - && s->c != Ctrl_A && !p_im) { + && s->c != Ctrl_A) { return 0; // exit insert mode } s->inserted_space = false; @@ -1236,7 +1203,7 @@ check_pum: } break; } - if (!ins_eol(s->c) && !p_im) { + if (!ins_eol(s->c)) { return 0; // out of memory } auto_format(false, false); @@ -1288,13 +1255,6 @@ check_pum: case Ctrl_L: // Whole line completion after ^X if (ctrl_x_mode != CTRL_X_WHOLE_LINE) { - // CTRL-L with 'insertmode' set: Leave Insert mode - if (p_im) { - if (echeck_abbr(Ctrl_L + ABBR_OFF)) { - break; - } - return 0; // exit insert mode - } goto normalchar; } FALLTHROUGH; @@ -7964,10 +7924,8 @@ static bool ins_esc(long *count, int cmdchar, bool nomove) } if (!arrow_used) { // Don't append the ESC for "r<CR>" and "grx". - // When 'insertmode' is set only CTRL-L stops Insert mode. Needed for - // when "count" is non-zero. if (cmdchar != 'r' && cmdchar != 'v') { - AppendToRedobuff(p_im ? "\014" : ESC_STR); + AppendToRedobuff(ESC_STR); } /* diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index ce3afba19b..f5fa424514 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -2880,10 +2880,6 @@ int do_ecmd(int fnum, char *ffname, char *sfname, exarg_T *eap, linenr_T newlnum redraw_curbuf_later(NOT_VALID); // redraw this buffer later } - if (p_im && (State & MODE_INSERT) == 0) { - need_start_insertmode = true; - } - // Change directories when the 'acd' option is set. do_autochdir(); @@ -4909,9 +4905,8 @@ void ex_help(exarg_T *eap) } } - if (!p_im) { - restart_edit = 0; // don't want insert mode in help file - } + restart_edit = 0; // don't want insert mode in help file + // Restore KeyTyped, setting 'filetype=help' may reset it. // It is needed for do_tag top open folds under the cursor. KeyTyped = old_KeyTyped; diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 6d1e1c073b..ae6d26227b 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -8979,7 +8979,6 @@ bool save_current_state(save_state_T *sst) sst->save_restart_edit = restart_edit; sst->save_msg_didout = msg_didout; sst->save_State = State; - sst->save_insertmode = p_im; sst->save_finish_op = finish_op; sst->save_opcount = opcount; sst->save_reg_executing = reg_executing; @@ -8987,7 +8986,6 @@ bool save_current_state(save_state_T *sst) msg_scroll = false; // no msg scrolling in Normal mode restart_edit = 0; // don't go to Insert mode - p_im = false; // don't use 'insertmode // Save the current typeahead. This is required to allow using ":normal" // from an event handler and makes sure we don't hang when the argument @@ -9010,7 +9008,6 @@ void restore_current_state(save_state_T *sst) // override the value of restart_edit anyway. restart_edit = sst->save_restart_edit; } - p_im = sst->save_insertmode; finish_op = sst->save_finish_op; opcount = sst->save_opcount; reg_executing = sst->save_reg_executing; diff --git a/src/nvim/ex_docmd.h b/src/nvim/ex_docmd.h index 874e0e599e..24656f3851 100644 --- a/src/nvim/ex_docmd.h +++ b/src/nvim/ex_docmd.h @@ -25,7 +25,6 @@ typedef struct { int save_restart_edit; bool save_msg_didout; int save_State; - int save_insertmode; bool save_finish_op; long save_opcount; int save_reg_executing; diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 1d496cbf25..3b1ff9ffed 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -1336,8 +1336,7 @@ static int command_line_execute(VimState *state, int key) } } - // CTRL-\ CTRL-N goes to Normal mode, CTRL-\ CTRL-G goes to Insert - // mode when 'insertmode' is set, CTRL-\ e prompts for an expression. + // CTRL-\ CTRL-N goes to Normal mode, CTRL-\ e prompts for an expression. if (s->c == Ctrl_BSL) { no_mapping++; allow_keys++; @@ -1399,9 +1398,6 @@ static int command_line_execute(VimState *state, int key) redrawcmd(); return command_line_not_changed(s); } else { - if (s->c == Ctrl_G && p_im && restart_edit == 0) { - restart_edit = 'a'; - } s->gotesc = true; // will free ccline.cmdbuff after putting it // in history return 0; // back to Normal mode diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 8881263d1c..005415514c 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -1352,14 +1352,12 @@ void openscript(char_u *name, bool directly) int oldcurscript; int save_State = State; int save_restart_edit = restart_edit; - int save_insertmode = p_im; int save_finish_op = finish_op; int save_msg_scroll = msg_scroll; State = MODE_NORMAL; msg_scroll = false; // no msg scrolling in Normal mode restart_edit = 0; // don't go to Insert mode - p_im = false; // don't use 'insertmode' clear_oparg(&oa); finish_op = false; @@ -1373,7 +1371,6 @@ void openscript(char_u *name, bool directly) State = save_State; msg_scroll = save_msg_scroll; restart_edit = save_restart_edit; - p_im = save_insertmode; finish_op = save_finish_op; } } @@ -2513,16 +2510,12 @@ static int vgetorpeek(bool advance) timedout = true; continue; } - // When 'insertmode' is set, ESC just beeps in Insert - // mode. Use CTRL-L to make edit() return. // In Ex-mode \n is compatible with original Vim behaviour. // For the command line only CTRL-C always breaks it. // For the cmdline window: Alternate between ESC and // CTRL-C: ESC for most situations and CTRL-C to close the // cmdline window. - if (p_im && (State & MODE_INSERT)) { - c = Ctrl_L; - } else if ((State & MODE_CMDLINE) || (cmdwin_type > 0 && tc == ESC)) { + if ((State & MODE_CMDLINE) || (cmdwin_type > 0 && tc == ESC)) { c = Ctrl_C; } else { c = ESC; diff --git a/src/nvim/main.c b/src/nvim/main.c index 80a856e91a..0ffd6cddff 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -530,11 +530,6 @@ int main(int argc, char **argv) // 'autochdir' has been postponed. do_autochdir(); - // start in insert mode - if (p_im) { - need_start_insertmode = true; - } - set_vim_var_nr(VV_VIM_DID_ENTER, 1L); apply_autocmds(EVENT_VIMENTER, NULL, NULL, false, curbuf); TIME_MSG("VimEnter autocommands"); diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 1692970a97..0c55c64b5c 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -1126,9 +1126,6 @@ static int normal_execute(VimState *state, int key) if (s->ca.nchar == ESC) { clearop(&s->oa); - if (restart_edit == 0 && goto_im()) { - restart_edit = 'a'; - } s->command_finished = true; goto finish; } @@ -1178,14 +1175,6 @@ static void normal_check_stuff_buffer(NormalState *s) // if wait_return still needed call it now wait_return(false); } - - if (need_start_insertmode && goto_im() && !VIsual_active) { - need_start_insertmode = false; - stuffReadbuff("i"); // start insert mode next - // skip the fileinfo message now, because it would be shown - // after insert mode finishes! - need_fileinfo = false; - } } } @@ -3904,7 +3893,6 @@ static void nv_regreplay(cmdarg_T *cap) /// Handle a ":" command and <Cmd> or Lua keymaps. static void nv_colon(cmdarg_T *cap) { - int old_p_im; bool cmd_result; bool is_cmdkey = cap->cmdchar == K_COMMAND; bool is_lua = cap->cmdchar == K_LUA; @@ -3930,8 +3918,6 @@ static void nv_colon(cmdarg_T *cap) compute_cmdrow(); } - old_p_im = p_im; - if (is_lua) { cmd_result = map_execute_lua(); } else { @@ -3940,15 +3926,6 @@ static void nv_colon(cmdarg_T *cap) cap->oap->op_type != OP_NOP ? DOCMD_KEEPLINE : 0); } - // If 'insertmode' changed, enter or exit Insert mode - if (p_im != old_p_im) { - if (p_im) { - restart_edit = 'i'; - } else { - restart_edit = 0; - } - } - if (cmd_result == false) { // The Ex command failed, do not execute the operator. clearop(cap->oap); @@ -6735,10 +6712,6 @@ static void nv_normal(cmdarg_T *cap) end_visual_mode(); // stop Visual redraw_curbuf_later(INVERTED); } - // CTRL-\ CTRL-G restarts Insert mode when 'insertmode' is set. - if (cap->nchar == Ctrl_G && p_im) { - restart_edit = 'a'; - } } else { clearopbeep(cap->oap); } @@ -6753,8 +6726,7 @@ static void nv_esc(cmdarg_T *cap) no_reason = (cap->oap->op_type == OP_NOP && cap->opcount == 0 && cap->count0 == 0 - && cap->oap->regname == 0 - && !p_im); + && cap->oap->regname == 0); if (cap->arg) { // true for CTRL-C if (restart_edit == 0 @@ -6771,9 +6743,8 @@ static void nv_esc(cmdarg_T *cap) // Don't reset "restart_edit" when 'insertmode' is set, it won't be // set again below when halfway through a mapping. - if (!p_im) { - restart_edit = 0; - } + restart_edit = 0; + if (cmdwin_type != 0) { cmdwin_result = K_IGNORE; got_int = false; // don't stop executing autocommands et al. @@ -6796,13 +6767,6 @@ static void nv_esc(cmdarg_T *cap) vim_beep(BO_ESC); } clearop(cap->oap); - - // A CTRL-C is often used at the start of a menu. When 'insertmode' is - // set return to Insert mode afterwards. - if (restart_edit == 0 && goto_im() - && ex_normal_busy == 0) { - restart_edit = 'a'; - } } // Move the cursor for the "A" command. @@ -6837,8 +6801,7 @@ static void nv_edit(cmdarg_T *cap) } else if ((cap->cmdchar == 'a' || cap->cmdchar == 'i') && (cap->oap->op_type != OP_NOP || VIsual_active)) { nv_object(cap); - } else if (!curbuf->b_p_ma && !p_im && !curbuf->terminal) { - // Only give this error when 'insertmode' is off. + } else if (!curbuf->b_p_ma && !curbuf->terminal) { emsg(_(e_modifiable)); clearop(cap->oap); } else if (!checkclearopq(cap->oap)) { diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 0be49aaad4..8ea55579bb 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -6719,7 +6719,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank) // remember it to make 'insertmode' work with mappings for // Visual mode. But do this only once and not when typed and // 'insertmode' isn't set. - if (p_im || !KeyTyped) { + if (!KeyTyped) { restart_edit_save = restart_edit; } else { restart_edit_save = 0; diff --git a/src/nvim/option.c b/src/nvim/option.c index 7dd7b41328..0d02bae5f7 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -4052,21 +4052,6 @@ static char *set_bool_option(const int opt_idx, char_u *const varp, const int va } else if ((int *)varp == &p_paste) { // when 'paste' is set or reset also change other options paste_option_changed(); - } else if ((int *)varp == &p_im) { - // when 'insertmode' is set from an autocommand need to do work here - if (p_im) { - if ((State & MODE_INSERT) == 0) { - need_start_insertmode = true; - } - stop_insert_mode = false; - } else if (old_value) { // only reset if it was set previously - need_start_insertmode = false; - stop_insert_mode = true; - if (restart_edit != 0 && mode_displayed) { - clear_cmdline = true; // remove "(insert)" - } - restart_edit = 0; - } } else if ((int *)varp == &p_ic && p_hls) { // when 'ignorecase' is set or reset and 'hlsearch' is set, redraw redraw_all_later(SOME_VALID); diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index 876acf2f87..0dc4bd1b90 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -334,9 +334,9 @@ EXTERN unsigned bo_flags; #ifdef IN_OPTION_C static char *(p_bo_values[]) = { "all", "backspace", "cursor", "complete", "copy", "ctrlg", "error", "esc", "ex", - "hangul", "insertmode", "lang", "mess", - "showmatch", "operator", "register", "shell", - "spell", "wildmode", NULL }; + "hangul", "lang", "mess", "showmatch", + "operator", "register", "shell", "spell", + "wildmode", NULL }; #endif // values for the 'belloff' option @@ -485,7 +485,6 @@ EXTERN char_u *p_iconstring; // 'iconstring' EXTERN int p_ic; // 'ignorecase' EXTERN int p_is; // 'incsearch' EXTERN char_u *p_icm; // 'inccommand' -EXTERN int p_im; // 'insertmode' EXTERN char_u *p_isf; // 'isfname' EXTERN char_u *p_isi; // 'isident' EXTERN char_u *p_isp; // 'isprint' diff --git a/src/nvim/options.lua b/src/nvim/options.lua index 809d4ab48b..a0fbf8d9f0 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -1250,9 +1250,9 @@ return { }, { full_name='insertmode', abbreviation='im', - short_desc=N_("start the edit of a file in Insert mode"), + short_desc=N_("No description"), type='bool', scope={'global'}, - varname='p_im', + varname='p_force_off', defaults={if_true=false} }, { diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 883de85aee..9c7b36396b 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -2540,9 +2540,7 @@ static int jump_to_help_window(qf_info_T *qi, bool newwin, int *opened_window) } } - if (!p_im) { - restart_edit = 0; // don't want insert mode in help file - } + restart_edit = 0; // don't want insert mode in help file return OK; } diff --git a/src/nvim/testdir/test_edit.vim b/src/nvim/testdir/test_edit.vim index bd080147fb..275c8f7a15 100644 --- a/src/nvim/testdir/test_edit.vim +++ b/src/nvim/testdir/test_edit.vim @@ -16,8 +16,9 @@ func Test_edit_00b() call setline(1, ['abc ']) inoreabbr <buffer> h here some more call cursor(1, 4) - " <c-l> expands the abbreviation and ends insertmode - call feedkeys(":set im\<cr> h\<c-l>:set noim\<cr>", 'tix') + " <esc> expands the abbreviation and ends insert mode + " call feedkeys(":set im\<cr> h\<c-l>:set noim\<cr>", 'tix') + call feedkeys("i h\<esc>", 'tix') call assert_equal(['abc here some more '], getline(1,'$')) iunabbr <buffer> h bw! @@ -234,15 +235,18 @@ func Test_edit_09() call setline(1, ['abc', 'def', 'ghi']) call cursor(1, 1) " 1) CTRL-\ CTLR-N - call feedkeys(":set im\<cr>\<c-\>\<c-n>ccABC\<c-l>", 'txin') + " call feedkeys(":set im\<cr>\<c-\>\<c-n>ccABC\<c-l>", 'txin') + call feedkeys("i\<c-\>\<c-n>ccABC\<esc>", 'txin') call assert_equal(['ABC', 'def', 'ghi'], getline(1,'$')) call setline(1, ['ABC', 'def', 'ghi']) " 2) CTRL-\ CTLR-G - call feedkeys("j0\<c-\>\<c-g>ZZZ\<cr>\<c-l>", 'txin') - call assert_equal(['ABC', 'ZZZ', 'def', 'ghi'], getline(1,'$')) - call feedkeys("I\<c-\>\<c-g>YYY\<c-l>", 'txin') - call assert_equal(['ABC', 'ZZZ', 'YYYdef', 'ghi'], getline(1,'$')) - set noinsertmode + " CTRL-\ CTRL-G goes to Insert mode when 'insertmode' is set, but + " 'insertmode' is now removed so skip this test + " call feedkeys("j0\<c-\>\<c-g>ZZZ\<cr>\<esc>", 'txin') + " call assert_equal(['ABC', 'ZZZ', 'def', 'ghi'], getline(1,'$')) + " call feedkeys("I\<c-\>\<c-g>YYY\<c-l>", 'txin') + " call assert_equal(['ABC', 'ZZZ', 'YYYdef', 'ghi'], getline(1,'$')) + " set noinsertmode " 3) CTRL-\ CTRL-O call setline(1, ['ABC', 'ZZZ', 'def', 'ghi']) call cursor(1, 1) @@ -1043,7 +1047,8 @@ endfunc func Test_edit_F1() " Pressing <f1> new - call feedkeys(":set im\<cr>\<f1>\<c-l>", 'tnix') + " call feedkeys(":set im\<cr>\<f1>\<c-l>", 'tnix') + call feedkeys("i\<f1>\<esc>", 'tnix') set noinsertmode call assert_equal('help', &buftype) bw diff --git a/src/nvim/testdir/test_normal.vim b/src/nvim/testdir/test_normal.vim index 1feffe1f8c..d1cb89bbd4 100644 --- a/src/nvim/testdir/test_normal.vim +++ b/src/nvim/testdir/test_normal.vim @@ -133,7 +133,8 @@ func Test_normal02_selectmode2() " some basic select mode tests call Setup_NewWindow() 50 - call feedkeys(":set im\n\<c-o>gHc\<c-o>:set noim\n", 'tx') + " call feedkeys(":set im\n\<c-o>gHc\<c-o>:set noim\n", 'tx') + call feedkeys("i\<c-o>gHc\<esc>", 'tx') call assert_equal('c51', getline('.')) " clean up bw! @@ -2113,11 +2114,11 @@ fun! Test_normal40_ctrl_bsl() call assert_equal('n', mode()) call assert_equal(1, col('.')) "imap <buffer> , <c-\><c-n> - set im + " set im exe ":norm! \<c-\>\<c-n>dw" - set noim + " set noim call assert_equal('are some words', getline(1)) - call assert_false(&insertmode) + " call assert_false(&insertmode) " clean up bw! diff --git a/test/functional/editor/mode_insert_spec.lua b/test/functional/editor/mode_insert_spec.lua index 684dee69db..e3d3cdbd85 100644 --- a/test/functional/editor/mode_insert_spec.lua +++ b/test/functional/editor/mode_insert_spec.lua @@ -6,8 +6,6 @@ local expect = helpers.expect local command = helpers.command local eq = helpers.eq local eval = helpers.eval -local meths = helpers.meths -local poke_eventloop = helpers.poke_eventloop describe('insert-mode', function() before_each(function() @@ -135,26 +133,4 @@ describe('insert-mode', function() feed('i<C-S-V><C-J><C-S-V><C-@><C-S-V><C-[><C-S-V><C-S-M><C-S-V><M-C-I><C-S-V><C-D-J><Esc>') expect('<C-J><C-@><C-[><C-S-M><M-C-I><C-D-J>') end) - - describe([[With 'insertmode', Insert mode is not re-entered immediately after <C-L>]], function() - before_each(function() - command('set insertmode') - poke_eventloop() - eq({mode = 'i', blocking = false}, meths.get_mode()) - end) - - it('after calling :edit from <Cmd> mapping', function() - command('inoremap <C-B> <Cmd>edit Xfoo<CR>') - feed('<C-B><C-L>') - poke_eventloop() - eq({mode = 'n', blocking = false}, meths.get_mode()) - end) - - it('after calling :edit from RPC #16823', function() - command('edit Xfoo') - feed('<C-L>') - poke_eventloop() - eq({mode = 'n', blocking = false}, meths.get_mode()) - end) - end) end) diff --git a/test/functional/legacy/edit_spec.lua b/test/functional/legacy/edit_spec.lua deleted file mode 100644 index 91d602924c..0000000000 --- a/test/functional/legacy/edit_spec.lua +++ /dev/null @@ -1,25 +0,0 @@ --- Test for edit functions --- See also: src/nvim/testdir/test_edit.vim - -local helpers = require('test.functional.helpers')(after_each) -local source = helpers.source -local eq, eval = helpers.eq, helpers.eval -local funcs = helpers.funcs -local clear = helpers.clear - -describe('edit', function() - before_each(clear) - - it('reset insertmode from i_ctrl-r_=', function() - source([=[ - call setline(1, ['abc']) - call cursor(1, 4) - call feedkeys(":set im\<cr>ZZZ\<c-r>=setbufvar(1,'&im', 0)\<cr>",'tnix') - ]=]) - eq({'abZZZc'}, funcs.getline(1,'$')) - eq({0, 1, 1, 0}, funcs.getpos('.')) - eq(0, eval('&im')) - end) - -end) - |