Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to disable Replace mode in vim?

Tags:

replace

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 replace mode. So, is there any way to completely disable Replace mode, whether through configuration setup or however?

like image 266
coderintherye Avatar asked Nov 05 '10 21:11

coderintherye


People also ask

How do I get out of replace mode?

1. Press the "Ins" key to toggle overtype mode off. Depending on your keyboard model, this key may also be labeled "Insert." If you simply want to disable overtype mode but keep the ability to toggle it back on, you are done.

How do I go to Vim normal mode?

By default, Vim starts in “normal” mode. Normal mode can be accessed from other modes by pressing Esc or <C-[> .

What are the three modes of Vim?

In Vim, there are three modes of operation: Normal, Insert, and Visual.


1 Answers

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
like image 70
ZyX Avatar answered Oct 11 '22 14:10

ZyX