0

我想制作一个脚本,它可以快速替换 unix 类型机器上的 .vimrc 文件。问题是在我正在工作的机器上,vim 不在 home 中,它不会在 home 文件夹中搜索 vimrc。

基本上,终端命令模拟什么是 Vim 中的 :echo $VIMRUNTIME。

4

2 回答 2

5
vim --cmd 'echo $VIMRUNTIME|q'
于 2014-07-16T05:42:48.593 回答
0

根据VIM 对 vimrc 的帮助

Four places are searched for initializations.  The first that exists
is used, the others are ignored.  The $MYVIMRC environment variable is
set to the file that was first found, unless $MYVIMRC was already set
and when using VIMINIT.
-  The environment variable VIMINIT (see also |compatible-default|) (*)
   The value of $VIMINIT is used as an Ex command line.
-  The user vimrc file(s):
        "$HOME/.vimrc"  (for Unix and OS/2) (*)
        "s:.vimrc"      (for Amiga) (*)
        "home:.vimrc"   (for Amiga) (*)
        "$VIM/.vimrc"   (for OS/2 and Amiga) (*)
        "$HOME/_vimrc"  (for MS-DOS and Win32) (*)
        "$VIM/_vimrc"   (for MS-DOS and Win32) (*)
    Note: For Unix, OS/2 and Amiga, when ".vimrc" does not exist,
    "_vimrc" is also tried, in case an MS-DOS compatible file
    system is used.  For MS-DOS and Win32 ".vimrc" is checked
    after "_vimrc", in case long file names are used.
    Note: For MS-DOS and Win32, "$HOME" is checked first.  If no
    "_vimrc" or ".vimrc" is found there, "$VIM" is tried.
    See |$VIM| for when $VIM is not set.
-  The environment variable EXINIT.
   The value of $EXINIT is used as an Ex command line.
-  The user exrc file(s).  Same as for the user vimrc file, but with
   "vimrc" replaced by "exrc".  But only one of ".exrc" and "_exrc" is
   used, depending on the system.  And without the (*)!

因此,您系统上的每个用户都可以将 .vimrc 隐藏在不同的位置,甚至可能以不同的方式命名。

你真的想剥夺用户随意定制 VIM 的自由吗?

于 2013-02-08T04:59:52.620 回答