Vim(看起来)忽略我的配置

发布于 2024-12-10 22:01:00 字数 646 浏览 0 评论 0原文

我每天在工作中使用 vim 已经快两年了,除了最近两天,我从来没有真正遇到过任何问题......

我最初的问题是,尽管我的设置是 vim 使用 8 个空格作为制表符.vimrc。它甚至拒绝让我从 vim 实例本身重置选项卡设置。此外,这个问题仅在编辑特定文件时发生,并且仅在它被命名为特定事物时才会发生(即,重命名它可以解决问题)。我认为这一定是由于我不知道的某种每文件配置造成的,一些搜索将我带到了另一篇文章,提示我尝试以下命令:

:so ~/.vimrc

这解决了我原来的问题,但我仍然不知道是什么造成的。我没有做任何我记得的事情,据我所知,它只是开始发生。

今天,我删除了一个交换文件,突然之间,单个文件的语法突出显示消失了(与受原始问题影响的文件相同)。同样,重命名文件可以解决问题,并且运行语法没有效果。这次 :so ~/.vimrc 并没有缓解这个问题。

有谁知道这里发生了什么吗?

更新: 感谢 Benoit 的建议,我发现我的 vim 正在查看 ~/.vim/view 中的文件以进行某些设置。当我移动这个文件时,问题就解决了(并且 vim 创建了一个新版本)。我仍然不能百分百确定发生了什么,但至少现在我有一些东西可以调查。

谢谢伯努瓦!!

I've been using vim daily at work for almost 2 years now, and I've never really had any issues except for in the last two days...

My initial problem was that vim was using 8 spaces for tabs despite my settings in .vimrc. It even refused to let me reset the tab settings from within the vim instance itself. Furthermore, this problem was only happening when editing a specific file, and only while it was named a specific thing (i.e., renaming it fixed the problem). I assumed this must be due to some kind of per-file configuration that I was unaware of, and some searching led me to another post which prompted me to try the following command:

:so ~/.vimrc

This fixed my original problem, but I still don't know what caused it. I didn't do anything that I recall, it just sort of started happening as far as I can tell.

Today I deleted a swap file and all of the sudden my syntax highlighting is gone for a single file (the same one that was affected by the original issue). Again, renaming the file fixes the problem, and it running syntax on has no effect. This time :so ~/.vimrc doesn't alleviate the problem.

Does anyone have any idea what is happening here?

Update:
Thanks to Benoit's suggestion I found out that my vim was looking at a file in ~/.vim/view for some settings. When I moved this file, the issue was resolved (and vim created a new version). I'm still not 100% sure happened, but at least now I have something to look into.

Thanks Benoit!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

最美不过初阳 2024-12-17 22:01:00

您的设置可能会被文件类型特定的文件修改。

要了解设置何时被修改:

:verbose set setting?

例如:

:verb set tabstop?
:verb set expandtab?
:verb set shiftwidth?

此外,您还可以找到适合您的文件类型的自动命令:

:autocmd *.ext

可能某些自动命令会设置文件类型,从而触发修改您的设置的 .vim 文件。

Your settings are probably modified by filetype specific files.

To know when a setting has been modified:

:verbose set setting?

for example:

:verb set tabstop?
:verb set expandtab?
:verb set shiftwidth?

Also, you could find autocmds for your file type:

:autocmd *.ext

probably some autocmd sets the file type, thus triggering .vim files that modify your settings.

无声情话 2024-12-17 22:01:00

FWIW,在过去的五年左右的时间里,我一直将 vim 设置保存在 ~/.exrc 中,没有遇到任何问题。

FWIW, I've kept my vim settings in ~/.exrc for the last half-decade or so, without trouble.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文