What determines the very first file that Vim will load on startup?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

What determines the very first file that Vim will load on startup?

DwigtArmyOfChampions
I am using Vim 7.4. I have a file /etc/vimrc, but when I vim a file and run the :scriptnames command, the very first file loaded is ~/.vimrc. 

On another Linux machine I also have Vim 7.4 installed, and when run the vim command and then run :scriptnames, that loads /etc/vimrc.

Where is this loading order determined? 

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/827c6d2e-a9ad-44ee-977e-4f4cfd17cb33%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: What determines the very first file that Vim will load on startup?

Ottavio Caruso
On Fri, 17 Jan 2020 at 13:10, DwigtArmyOfChampions
<[hidden email]> wrote:
>
> I am using Vim 7.4. I have a file /etc/vimrc, but when I vim a file and run the :scriptnames command, the very first file loaded is ~/.vimrc.
>
> On another Linux machine I also have Vim 7.4 installed, and when run the vim command and then run :scriptnames, that loads /etc/vimrc.
>
> Where is this loading order determined?

I have this is my help file:

                                                   system-vimrc
     b. For Unix, MS-DOS, MS-Windows, OS/2, VMS, Macintosh, RISC-OS and Amiga
        the system vimrc file is read for initializations.  The path of this
        file is shown with the ":version" command.  Mostly it's "$VIM/vimrc".
        Note that this file is ALWAYS read in 'compatible' mode, since the
        automatic resetting of 'compatible' is only done later.  Add a ":set
        nocp" command if you like.
        For the Macintosh the $VIMRUNTIME/macmap.vim is read.

          VIMINIT .vimrc _vimrc EXINIT .exrc _exrc $MYVIMRC



$ vim --version
[...]
   system vimrc file: "/usr/pkg/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/pkg/share/vim"

echo $VIM
/usr/pkg/share/vim



--
Ottavio Caruso

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAEJNuHy3NVMLeqvzUyoE3uW_%2BKspfLqmpQXbB%3D-p7jmie%2BRHyg%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: What determines the very first file that Vim will load on startup?

Tony Mechelynck
In reply to this post by DwigtArmyOfChampions
On Fri, Jan 17, 2020 at 2:10 PM DwigtArmyOfChampions
<[hidden email]> wrote:
>
> I am using Vim 7.4. I have a file /etc/vimrc, but when I vim a file and run the :scriptnames command, the very first file loaded is ~/.vimrc.
>
> On another Linux machine I also have Vim 7.4 installed, and when run the vim command and then run :scriptnames, that loads /etc/vimrc.
>
> Where is this loading order determined?

The first file sourced at startup is the "system vimrc" — if it
exists. Its default name is $VIM/vimrc (with no initial period to the
filename) but the path can be modified at compile time; on most
versions of Vim distributed as part of Linux distributions the system
vimrc, if it exists, is at /etc/vimrc. Its path for a given Vim
executable can be found near the middle of the output of the :version
command. If you have different Vim executables on the same machine,
looking for their system vimrc scripts at different places, and you
want them to use the same script (for all users — all login names — on
that system) you can put at one of these locations a symlink to the
other one. The recommended procedure is to use one ~/.vimrc (see
below) per user; if a single person can login under more than one
username it is possible to maintain one .vimrc and set symlinks for
the other usernames'.

If there is no "vimrc" file where Vim looks for the system vimrc, that
is no error, and Vim just goes on to the next startup step, which is
looking in several places for your user vimrc. Again, not finding it
is no error, and if it is not found, modern versions of Vim (starting
at Vim 8.0) source $VIMRUNTIME/defaults.vim, unless they have been
specifically ordered not to load it, e.g. by having -u NONE on the
command-line.

For details, see ":help startup" and in particular its steps b (:help
system-vimrc) and c (:help .vimrc).

BTW, Vim 7.4 is getting a little long in the teeth: the current
version as of this writing is 8.2.124.

Best regards,
Tony.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAJkCKXt%3D_MoCc4VsE%3D3psVQSva7CouzrPcBofO2L%3De-AhgzxOQ%40mail.gmail.com.