Bill McCarthy wrote:
Hello Vim List,

Suppose two plugins define autocmds, so after start Vim,

    :au FuncUndefined

displays:

    *         call AsNeeded(1,expand("<afile>"))
    Tlist_*   source C:\vim\vimfiles\plugin\taglist.vim

Now I add a line to my _vimrc:

    au! FuncUndefined * call Foo()

Now after starting Vim and typing :au FuncUndefined

    *         call Foo()
              call AsNeeded(1,expand("<afile>"))
    Tlist_*   source C:\vim\vimfiles\plugin\taglist.vim

It did not replace!

Now removing the line I added to _vimrc, starting Vim and
typing :au! FuncUndefined * call Foo()

I get what I expected from :au FuncUndefined

    Tlist_*   source C:\vim\vimfiles\plugin\taglist.vim
    *         call Foo()

Vim only appears to fail in startup - it is not just a
script error.  If I write a small script file that just
contains the line:  au! FuncUndefined * call Foo()

Sourcing that script works just like typing the command.


The vimrc is sourced before the plugins. To have a command executed after the plugins have been sourced, either place it in an "after-directory", for instance in a script named (on Windows) "~/vimfiles/after/plugin/zzzzlast.vim", or else place it in an autocommand for the VimEnter event, which is triggered at the very end of startup:

  au VimEnter * au! FuncUndefined * call Foo()


Best regards,
Tony.

Reply via email to