0

Some vim plugins provides functions especially designed to be used for statusline rendering. For example, in my .vimrc I create the status line format string like this:

...
set statusline+=%{SyntasticStatuslineFlag()}
...

and status line of my windows contain some summary of problems detected by Syntastic plugin.

Now the problem is that on some of my machines the Syntastic plugin is not installed. The statusline on the machines w/o the plugin should not contain the SyntasticStatuslineFlag() call, but I still want to use my standard .vimrc on all my machines.

I can't check availability of the function in .vimrc because at the time .vimrc is processed plugins are not loaded yet.

What is the best way to construct statusline in .vimrc and avoid this problem?

2

Simply use ternaries in the statusline:

set statusline+=%{exists('*SyntasticStatuslineFlag')?SyntasticStatuslineFlag():''}

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.