是否可以在 vim 中禁用替换模式? [英] Is it possible to disable Replace mode in vim?

查看:63
本文介绍了是否可以在 vim 中禁用替换模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

简而言之,如何在 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?

推荐答案

您不能禁用替换模式,但您可以创建自动命令,将替换和虚拟替换模式改回插入模式:

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

这篇关于是否可以在 vim 中禁用替换模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆