I have a plugin (FindFile.vim) that needs to run :FindFileCache . whenever I start vim to gather a file cache for quick opening.. I have to run this every time I start vim though.
How might I write a command that runs once, every time that vim starts up?
The best place to keep your configuration stuff is in your .vimrc
file. However, it’s sourced too early, check
:h startup:As you can see, your .vimrc will be loaded before plugins. If you put
:FindFileCache .in it an error will occur, since that command does not exist yet. (It will exist once the plugin is loaded in step 4.)To solve this, instead of executing the command directly, create an
auto-command. Auto-commands execute some command when an event occurs. In this case, the VimEnter event looks appropriate (from
:h VimEnter):Then, just place this line in your .vimrc: