Ich weiß aus Erfahrung, dass die Datei ~/.exrc verwendet werden kann, um vim
zu konfigurieren . Ich weiß auch, dass die Datei ~/.vimrc für denselben Zweck verwendet werden kann.
Wenn ich jedoch .exrc verwende, um vim
zu konfigurieren , führt dies zu Problemen auf Systemen, auf denen vi
statt vim
installiert . Nämlich vim
unterstützt zusätzliche Funktionen, die vi
nicht; und wenn Sie versuchen, sie in vi
zu verwenden , vi
beschwert.
Meine Fragen sind:
- Was ist der Unterschied zwischen .exrc und .vimrc?
- Wenn beide vorhanden sind, dann sind es beide verwendet?
- Ist es schlechte Praxis, die .exrc-Datei zu verwenden, um
vim
zu konfigurieren ?
Akzeptierte Antwort:
-
.exrc ist die Konfigurationsdatei für
vi
, während .vimrc die Konfigurationsdatei fürvim
ist -
Nein. Vim verwendet die .vimrc-Datei, falls vorhanden, andernfalls die .exrc-Datei, falls vorhanden
-
Ja, es sei denn, Sie geben dort nur vi-kompatible Befehle ein
Aus der Vim-Hilfe auf exrc:
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 (*)!