开发者

Is it possible to disable Replace mode in vim?

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 replac开发者_如何学Pythone mode. So, is there any way to completely disable Replace mode, whether through configuration setup or however?


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


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>


Just add in your .vimrc imap <Insert> <Nop>

That will be enough


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)


Use I key to go into Insert instead of using the Insert key

That way you will not re-enter Insert mode

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜