gpt4 book ai didi

linux - 带有空 .vimrc 的退格键的 Vim 怪异行为

转载 作者:太空狗 更新时间:2023-10-29 11:12:14 24 4
gpt4 key购买 nike

我在 Ubuntu 上遇到 vim 的奇怪问题。过去几周我一直在使用它,试图在 Windows 上学习它,现在我在 Linux 上使用它时它的行为有所不同。

我注意到,在插入模式下,按退格键会像 Windows 上的任何其他编辑器一样删除文本,但在 Linux 上,文本会“删除”,但它会一直保留在那里,直到我按 ESC 键或覆盖它为止。

我试图解决这个问题,但我很困惑这是否是有意为之的行为。它也发生在 gvim 中。

这个问题的原因是这样的,然而:

我删除了我的 .vimrc 文件以查看我的配置是否有问题并修复了它。退格键现在又回到了原来的状态。

但后来我尝试创建一个空的 .vimrc 文件,这使它返回到延迟删除。它是空的。到底为什么?

所以我不知道是什么原因造成的。希望我的问题有意义我的英语不是最好的。谢谢。


好吧,看看 :h compatible 我发现了这个:

"When a |vimrc| or |gvimrc| file is found while Vim is starting up, this option is switched off, and all options that have not been modified will be set to the Vim defaults. Effectively, this means that when a |vimrc| or |gvimrc| file exists, Vim will use the Vim defaults, otherwise it will use the Vi defaults. (Note: This doesn't happen for the system-wide vimrc or gvimrc file, nor for a file given with the |-u| argument). Also see |compatible-default| and |posix-compliance|."

所以如果我做对了,运行带有 .vimrc 文件的 Vim 应该自动设置 nocompatible 并且在没有 .vimrc 文件的情况下运行它应该设置 compatible...?无论如何,我尝试检查 :verbose set compatible?它总是说不兼容,所以 -N 标志不应该做任何事情......但它解决了这个问题。

最佳答案

如果没有 vimrc,Vim 将加载 /usr/share/vim/vim80/defaults.vim(取决于你的 vim 版本)。在此文件中,bs/backspace 参数设置为 2,或者实际上是 indent,eol,start这与 2 相同(参见 :h bs)

现在如果你创建一个空的 .vimrcdefaults.vim 将不会被加载,所以你的 bs 可能是 0。

此行为在 :h defaults.vim 中描述

所以要解决您的问题,只需将 set bs=2 放入您的 .vimrc

关于linux - 带有空 .vimrc 的退格键的 Vim 怪异行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47072670/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com