Put simply, how can I completely disable Replace mode in vim? I never use Replace mode, but I sometimes end up in it by accident when re-entering Insert Mode. Naturally, I goof up by typing over a few characters before realizing I am in replace mode. So, is there any way to completely disable Replace mode, whether through configuration setup or however?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You cannot disable replace mode, but you can make autocommands which will change Replace and Virtual Replace modes back to Insert mode:
function s:ForbidReplace()
if v:insertmode isnot# 'i'
call feedkeys("\<Insert>", "n")
endif
endfunction
augroup ForbidReplaceMode
autocmd!
autocmd InsertEnter * call s:ForbidReplace()
autocmd InsertChange * call s:ForbidReplace()
augroup END
回答2:
Not sure if this is the best way, but you could map R and r to nothing in your .vimrc:
map R <C-V><C-V>
map r <C-V><C-V>
Edit: or this:
map R <Nop>
map r <Nop>
回答3:
Just add in your .vimrc imap <Insert> <Nop>
That will be enough
回答4:
I found this solution better. Insert key to enter insert mode works, but replace mode on second insert hit is disabled. Place next two lines into your .vimrc
imap <Insert> <Nop>
inoremap <S-Insert> <Insert>
(mentioned by garyjohn @ superuser site)
回答5:
Use I key to go into Insert instead of using the Insert key
That way you will not re-enter Insert mode