Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the load order of scripts when you start up vim?

Tags:

vim

If you start up vim with something like this:

vim -S myscript.vim file.txt 

What is the load order of scripts? Does myscript.vim get loaded after or before ~/.vimrc.

If you pass in vimscript commands to vim directly on the command line, when do they get executed relative to sourced and default vimscripts?

like image 552
dan Avatar asked Dec 16 '10 18:12

dan


People also ask

Where does Vim look for Vimrc?

vimrc , and Vim files of current user are located inside ~/. vim/ . The global configuration file is located at /etc/vimrc .

How do I run a script in Vim?

You can always execute Vimscript by running each command in command mode (the one you prefix with : ), or by executing the file with commands using a :source command. Historically, Vim scripts have a . vim extension. Here, :so is a short version of :source , and % refers to the currently open file.


2 Answers

I believe vimrc is always first. You can run :scriptnames to get a list of sourced scripts in order in which they were first sourced in your Vim instance.

like image 121
Herbert Sitz Avatar answered Sep 17 '22 17:09

Herbert Sitz


The help entry is way too long to post here, but it lists the order of everything that vim does at initialization. See :help initialization.

like image 35
Randy Morris Avatar answered Sep 20 '22 17:09

Randy Morris