Search code examples
vimvim-plugin

VimL: Checking if function exists


right now I'm cleaning up my .vimrc file to make sure it's compatible on most systems.

In my statusline I use a function that another plugin sets, the GitBranchInfoString() function introduced by this plugin.

What I wanna do is check if this function is set, and only then add it to the statusline. It would be in it's own line so I just need to check for it.

What would be the simplest way to accomplish this?

Thanks for all your help!

EDIT:

I have the following:

if exists('*GitBranchInfoString')
    let &stl.='%{GitBranchInfoString()}'
endif

Solution

  • Use

    if exists("*GitBranchInfoString")
        " do stuff here
    endif