.exrc 和 .vimrc 有什么区别?

.exrc 和 .vimrc 有什么区别?

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

但是,如果我使用 .exrc 来配置vim,这会导致vi安装了 的系统而不是vim.即,支持不支持vim的额外功能;vi当你尝试在 中使用它们时vivi会抱怨。

我的问题是:

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

答案1

  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 (*)!

相关内容