[英]How to locate the vimrc file used by Vim?
Is there a command in the Vim editor to find the .vimrc
file location? Vim编辑器里有没有找到
.vimrc
文件位置的命令?
Just try doing the following:只需尝试执行以下操作:
:version
You will get an output which includes something like:您将获得一个输出,其中包括以下内容:
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
user exrc file: "$HOME/.exrc"
system gvimrc file: "$VIM/gvimrc"
user gvimrc file: "$HOME/.gvimrc"
system menu file: "$VIMRUNTIME/menu.vim"
As noted by Herbert in comments, this is where vim
looks for vimrc
s, it doesn't mean they exist.正如 Herbert 在评论中指出的那样,这是
vim
寻找vimrc
的地方,这并不意味着它们存在。
You can check the full path of your vimrc
with您可以检查
vimrc
的完整路径
:echo $MYVIMRC
If the output is empty, then your vim
doesn't use a user vimrc
(just create it if you wish).如果输出为空,则您的
vim
不使用用户vimrc
(如果您愿意,只需创建它)。
对于nvim
使用:scriptnames
就像Randy Morris 评论中提出的那样
:version 没有列出/etc/vim但这是 vim 在我从 vim-gtk3 运行 vim82 的 ubuntu 盒子上拾取 gvimrc 和 vimrc 的地方
If the existing answers do not help, run :script
which will show you all the locations where VIM is loading files from.如果现有的答案没有帮助,请运行
:script
它将向您显示 VIM 从中加载文件的所有位置。 Probably, your source file is located somewhere in those directories.您的源文件可能位于这些目录中的某处。 If you find a different source file, you may insert the following in it:
如果您找到不同的源文件,您可以在其中插入以下内容:
if filereadable("/my/directory/.vim/.vimrc")
source /my/directory/.vim/.vimrc
endif
And VIM will load your custom config file wherever it is. VIM 将加载您的自定义配置文件,无论它在哪里。
Check it is working by looking for it in the output of :script
通过在
:script
的 output 中查找它来检查它是否正常工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.