docs: improve 'insertmode' emulation #18962

The current emulation script enters Insert mode much too frequently.
Using only BufWinEnter seems to be a closer simulation.

Also add a few more mappings.
This commit is contained in:
zeertzjq 2022-06-17 08:16:33 +08:00 committed by GitHub
parent c57f6b28d7
commit 1fe94cb008
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -550,10 +550,31 @@ Options:
*'imstatusfunc'* *'imsf'* *'imstatusfunc'* *'imsf'*
*'insertmode'* *'im'* Use the following script to emulate 'insertmode': *'insertmode'* *'im'* Use the following script to emulate 'insertmode':
> >
autocmd VimEnter,CmdlineLeave,WinEnter,WinScrolled,BufEnter * silent! if &modifiable | startinsert | endif autocmd BufWinEnter * startinsert
inoremap <Esc> <Nop> inoremap <Esc> <C-X><C-Z><C-]>
inoremap <C-L> <Esc> inoremap <C-C> <C-X><C-Z>
nnoremap <Esc> i inoremap <C-L> <C-X><C-Z><C-]><Esc>
inoremap <C-Z> <C-X><C-Z><Cmd>suspend<CR>
noremap <C-C> <Esc>
snoremap <C-C> <Esc>
noremap <C-\><C-G> <C-\><C-N><Cmd>startinsert<CR>
cnoremap <C-\><C-G> <C-\><C-N><Cmd>startinsert<CR>
inoremap <C-\><C-G> <C-X><C-Z>
autocmd CmdWinEnter * noremap <buffer> <C-C> <C-C>
autocmd CmdWinEnter * inoremap <buffer> <C-C> <C-C>
lua << EOF
vim.on_key(function(c)
if c == '\27' then
local mode = vim.api.nvim_get_mode().mode
if mode:find('^[nvV\22sS\19]') and vim.fn.getcmdtype() == '' then
vim.schedule(function()
vim.cmd('startinsert')
end)
end
end
end)
EOF
< <
*'macatsui'* *'macatsui'*
*'maxcombine'* *'mco'* *'maxcombine'* *'mco'*