Does Vim load plugins after loading vimrc?

Besides scriptnames, to see what order vim runs things in on startup, you can also use:

vim --startuptime <file>

so it will log all the tasks it does in order, and how much time each one takes.


Yes. vimrc is loaded before plugins.

If you look at :h initialization you will find that step 3 is load vimrc and step 4 is load plugins.

You can also see that vimrc is loaded before plugins by looking at the output of :scriptnames. scriptnames lists all sourced scripts in the order they were sourced and vimrc is the first thing sourced. (Take a look at :h :scriptnames).


To fix the highlighting you just need to run the highlight commands after the plugin gets sourced. To do this you put files in the after directory of your .vim directory. (Take a look at :h after-directory)

So create the file .vim/after/plugin/hicursorwords.vim with the following contents

highlight clear WordUnderTheCursor                             
highlight WordUnderTheCursor cterm=bold ctermfg=254 ctermbg=160

This will cause the plugin to be sourced before you change the settings of the plugin.

(This of course assumes you don't want to edit the plugin)

Tags:

Vim