2

On my Ubuntu OS, I see this in /etc/vim/vimrc.tiny:

$ cat /etc/vim/vimrc.tiny
" Vim configuration file, in effect when invoked as "vi".

Here's the partial output from :version:
system vimrc file: "$VIM/vimrc"

It looks like the VIM environment variable is not defined - echo $VIM doesn't show anything.

So how does vi know to read /etc/vim/vimrc.tiny?

  • from within vim, check the output of echo $VIM – Christian Brabandt Mar 11 '19 at 10:02
  • 1
    If :echo $VIM from within Vim prints E319: Sorry, the command is not available in this version, try :!echo $VIM. – Ralf Mar 11 '19 at 11:01
  • Then try e.g. :e $VIM/vimrc and use <c-g> to find its path. Alternatively, if :shell works, check there the value of $VIM – Christian Brabandt Mar 11 '19 at 11:41
  • From the above methods, I found $VIM to be /usr/share/vim. So following the :verson output, I would think that the system vimrc file is /usr/share/vim/vimrc. However, $ ll /usr/share/vim/vimrc shows it's point to /usr/share/vim/vimrc -> /etc/vim/vimrc, not /etc/vim/vimrc.tiny, and there is no mention of .tiny in /etc/vim/vimrc. So it's not still unclear how the .tiny file is used. – flow2k Mar 12 '19 at 6:56
2

This is not a answer to your question, but a follow up on you comment:

From the above methods, I found $VIM to be /usr/share/vim. So following the :version output, I would think that the system vimrc file is /usr/share/vim/vimrc. However, $ ll /usr/share/vim/vimrc shows it's point to /usr/share/vim/vimrc -> /etc/vim/vimrc, not /etc/vim/vimrc.tiny, and there is no mention of .tiny in /etc/vim/vimrc. So it's not still unclear how the .tiny file is used.


You have /etc/vim/vimrc and /etc/vim/vimrc.tiny, because you installed multiple vim-related packages on Ubuntu.

  • /etc/vim/vimrc.tiny is from the package "vim-tiny".
  • /etc/vim/vimrc is from the package "vim-common"

In a default setup of Ubuntu only "vim-tiny" is installed. This is a small Vim build with limited features (e.g. no syntax highlighting). This package also created the file /usr/share/vim/vimrc as a symbolic link to /etc/vim/vimrc.tiny.

Later on a "bigger" Vim package was installed, like "gvim". This has a dependency on "vim-common". The package "vim-common" contains all the runtime files (syntax highlighting etc). This package also creates the file /usr/share/vim/vimrc, but this time as a symbolic link to /etc/vim/vimrc.

So: The file /etc/vim/vimrc.tiny is from the package "vim-tiny" and is not used anymore. The package is still installed and you can call the executable with

$ vim.tiny

To see all installed vim-related packages execute

$ dpkg -l \*vim\*
| improve this answer | |
  • Ralf, thanks for sharing this. So you're saying when I invoke vi, /etc/vim/vimrc is read? I took a look at this file /etc/vim/vimrc, but it does not set compatible. So why is vi running in "compatible mode"? /etc/vim/vimrc.tiny does set compatible, which why I suspected the .tiny file is being used. – flow2k Mar 14 '19 at 22:48
  • 1
    I explain why you have vimrc.tiny and vimrc in /etc/vim, as you asked in a comment. Which files are read can be displayed by executing :scriptnames. – Ralf Mar 15 '19 at 5:08
  • 1
    BTW: compatible is the default. See :help compatible. When that help text mention vimrc , it talks about $HOME/.vimrc (or $HOME/.vim/vimrc). – Ralf Mar 15 '19 at 5:35
  • :scriptnames is not available in this version. But you've answered my question. Thanks. – flow2k Mar 15 '19 at 6:53
  • This answer was initially meant as a follow up on one of you comments. I updated it to make that clear. – Ralf Mar 15 '19 at 8:15
2

Have a look at :h VIMINIT there is a list of places vim looks for a config, and it will use the first one found:

Most used are the user vimrc files:

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

But there is also a backup and systemwide files. Have a look at the help since it is somewhat different depending on version,

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.