.vimrc 必须位于主目录中吗?

E. *_*rok 1 vim terminal

我刚刚将 .vimrc、.vimrc~、..vimrc.un~ 文件从我的主目录移动到名为 .vim 的文件夹中。现在,当我在 vim 中编辑文件时,我在 .vimrc 中所做的所有首选项都不起作用。然后我将 .vimrc 文件移回到我的主目录中,突然之间我的首选项又恢复正常了。

这让我想知道:.vimrc 是否需要位于主目录中?如果是这样,为什么?有什么办法可以改变这种情况吗?

我是 vim 的新手,所以任何帮助将不胜感激。谢谢!

rom*_*inl 5

尝试随机的事情是一种失败的策略。相反,请考虑阅读相关文档并正确执行操作。从:help vimrc

[...]

Places for your personal initializations:
    Unix          $HOME/.vimrc or $HOME/.vim/vimrc
    MS-Windows    $HOME/_vimrc, $HOME/vimfiles/vimrc
                  or $VIM/_vimrc
    Amiga         s:.vimrc, home:.vimrc, home:vimfiles:vimrc
                  or $VIM/.vimrc
    Haiku         $HOME/config/settings/vim/vimrc

The files are searched in the order specified above and only the first
one that is found is read.

RECOMMENDATION: Put all your Vim configuration stuff in the
$HOME/.vim/ directory ($HOME/vimfiles/ for MS-Windows). That makes it
easy to copy it to another system.

[...]
Run Code Online (Sandbox Code Playgroud)