2

I'm enforcing some strange behaviour of Vundle plugin. Basically, from time to time, i'm not able to install new plugins using :PluginInstall because Vundle can't see the new Plugin entries in my .vimrc file. The results displayed by :PluginInstall contains few plugins from .vimrc but not the recently added ones. I was able to fix that temporary by closing MacVim, opening a terminal vim and running PluginInstall there but it stopped working and now i'm completely not able to install new plugins anywhere.

It behaves like the .vimrc file has been cached somewhere but i can't find such cached one and there is no any .vimrc.swp file present so i feel quite lost.

Any help much appreciated.

  • Hi @mbajur can you post a link to your vimrc. – Franklin B Nov 4 '15 at 16:15
  • sure, here you go: gist.github.com/mbajur/ab5fabf80cd7e000b230 – mbajur Nov 4 '15 at 21:47
  • 1
    What you describe sounds a bit to me like you don't source your .vimrc. Try to open vim again, run :edit $MYVIMRC, make your changes and save them with :w, then source the .vimrc with :source %, and then run :PluginInstall. Does the error persist? – cbaumhardt Nov 5 '15 at 0:58
  • yes, that helped :) However, i'm not sure if that's just working temporary or will occur again in a day or two. Anyway - is that normal? Should i always source my vimrc before :PluginInstall ? (post your comment as an answer and i'm gonna accept it) – mbajur Nov 5 '15 at 8:27
4

Vim parses your .vimrc once when it is started. Whenever you change something in it (in your case add a new plugin), vim needs to be told manually that something changed so that the .vimrc gets parsed again. You do that by running :source $MYVIMRC. I often shorten that to :so % when my .vimrc is opened (% gets expanded to current file name).

After sourcing your .vimrc, all saved changes are processed and should take effect, so you can run your :PluginInstall command.

In general, your :PluginInstall command will only work if the .vimrc was sourced. What you can do to save you doing this small step manually over and over again is to automate it:

augroup reload_vimrc " {
    autocmd!
    autocmd BufWritePost $MYVIMRC source $MYVIMRC
augroup END " }

That way, whenever you save changes to your .vimrc, it gets sourced automatically.

  • great answer! I was sure that PluginInstall loads .vimrc on it's own each time i'm running it. Thank you for clarification. – mbajur Nov 9 '15 at 8:14

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.