Vim - how to run a command immediately when starting vim?

前端 未结 5 489
野的像风
野的像风 2020-12-02 06:46

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

5条回答
  •  -上瘾入骨i
    2020-12-02 07:22

    To get even later than other answers but still just after startup, use a timer in .vimrc. For example, this code in .vimrc waits half a second after startup before setting a variable.

    function DelayedSetVariables(timer)
        let g:ycm_filetype_blacklist['ignored'] = 1
    endfunction
    let timer=timer_start(500,'DelayedSetVariables')
    

    (The variable in the example is the blacklist from YouCompleteMe plugin. I assume, the plugin starts up some other process asynchronously which then creates variables, but is not quite ready by the time vim has started. The variable does not exist when I try to set it in .vimrc, an after file, or VimEnter event. This is specific to my Windows system somehow, YCM documentation says .vimrc should work for setting options.)

提交回复
热议问题