.exrc和.vimrc有什么区别?


13

我从经验中知道〜/ .exrc文件可用于配置vim。我也知道〜/ .vimrc文件可以用于相同的目的。

但是,如果使用.exrc进行配置vim,则会导致在vi安装而不是的系统上出现问题vim。即,vim支持vi不支持的其他功能;当您尝试在中使用它们时vi,会vi抱怨。

我的问题是:

  1. .exrc和.vimrc有什么区别?
  2. 如果两者都存在,那么使用吗?
  3. 使用.exrc文件进行配置是不好的做法vim吗?

Answers:


14
  1. .exrc是的配置文件vi,而.vimrc是的配置文件vim

  2. 不,Vim将使用.vimrc文件(如果存在),否则使用.exrc文件(如果存在)

  3. 是的,除非您仅在其中放置vi兼容命令

从exrc的Vim帮助中:

 c. 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) (*)
        "$HOME/.vim/vimrc"     (for Unix and OS/2) (*)
        "s:.vimrc"         (for Amiga) (*)
        "home:.vimrc"      (for Amiga) (*)
        "home:vimfiles:vimrc"  (for Amiga) (*)
        "$VIM/.vimrc"      (for OS/2 and Amiga) (*)
        "$HOME/_vimrc"     (for MS-DOS and Win32) (*)
        "$HOME/vimfiles/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 (*)!
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.