The question is specifically about CentOS7, and mentions vim. That can only be one of a few packages: vim-minimal
, vim-enhanced
, vim-x11
. CentOS does not provide packages for other implementations of vi, such as nvi
.
The package description for vim-minimal
says
The vim-minimal package includes a minimal version of
VIM, which is installed into /bin/vi for use when only the root
partition is present.
and man vi
gives the vim manpage, which lists the system configuration files used:
/etc/vimrc System wide Vim initializations.
/etc/gvimrc System wide gvim initializations.
and since there is no mention of gvim
, the proper answer is /etc/vimrc
.
Note that vim's documentation does not list a different configuration file when running as vi
. There are no /etc/virc
or ~/.virc
files.
Actually, POSIX avoids telling where any system configuration files might reside. Keith Bostic (who wrote most of the POSIX description of vi) used a different system configuration file for nvi
:
/etc/vi.exrc
Besides not mentioning system configuration files, Bostic also chose not to document modelines (or implement them in nvi
). The two are related. Other implementations of vi
provide (optionally or not) a way to read a configuration file from the current directory. That can lead to unexpected results, and modelines can aggravate that. The Unix systems (AIX, HPUX, Solaris) make these features optional (as do elvis
, and vim
), based on the settings exrc
and modeline
. nvi
also uses the exrc
setting for the same purpose.
vim's manpage does not mention, but the help/documentation does say that if it cannot find a suitable ~/.vimrc
, it will look for /.exrc
(no /etc/exrc
). The ~/.exrc
was documented for SunOS 4. Solaris 10 likewise mentions ~/.exrc
, but not /etc/exrc
.
Further reading:
find /etc -name vimrc
– Costas Jan 23 '15 at 20:18source
in$EXINIT
.~/.exrc
and$EXINIT
are always ignored when callingvi/ex/open
on a file named-
though. – mikeserv Jan 23 '15 at 21:04