本文翻译自:Where is my .vimrc file?
I have been using Vim , and I would really like to save my settings. 我一直在使用Vim ,我真的很想保存我的设置。 The problem I am having is that I cannot find my .vimrc file, and it is not in the standard /home/user/.vimrc
location. 我遇到的问题是我找不到我的.vimrc文件,并且它不在标准的/home/user/.vimrc
位置。 How might I find this file? 我如何找到该文件?
#1楼
参考:https://stackoom.com/question/jpAH/我的-vimrc文件在哪里
#2楼
You need to create it. 您需要创建它。 In most installations I've used it hasn't been created by default. 在大多数安装中,我使用过的不是默认情况下创建的。
You usually create it as ~/.vimrc
. 您通常将其创建为~/.vimrc
。
#3楼
:scriptnames
list all the .vim files that Vim loaded for you, including your .vimrc
file. :scriptnames
列出Vim为您加载的所有.vim文件,包括您的.vimrc
文件。
:e $MYVIMRC
open & edit the current .vimrc that you are using, then use Ctrl + G to view the path in status bar. :e $MYVIMRC
打开和编辑您正在使用,然后使用Ctrl + G以查看状态栏中的路径当前的.vimrc。
#4楼
Here are a few more tips: 这里有一些提示:
In Arch Linux the global one is at
/etc/vimrc
. 在Arch Linux中 ,全局目录位于/etc/vimrc
。 There are some comments in there with helpful details. 那里有一些注释,其中包含有用的详细信息。Since the filename starts with a
.
由于文件名以开头.
, it's hidden unless you usels -a
to show ALL files. ,除非您使用ls -a
显示所有文件,否则它是隐藏的。Typing
:version
while in Vim will show you a bunch of interesting information including the file location. 在Vim中输入:version
会显示很多有趣的信息,包括文件位置。If you're not sure what
~/.vimrc
means look at this question . 如果您不确定~/.vimrc
是什么意思,请查看此问题 。
#5楼
:echo($MYVIMRC)
will give you the location of your .vimrc file. 将为您提供.vimrc文件的位置。
:e $MYVIMRC
will open it. 将其打开。
#6楼
作为附加信息,主要在macOS中,.vimrc文件位于目录中:
/usr/share/vim/.vimrc