【发布时间】:2013-12-10 00:20:43
【问题描述】:
我在许多机器上使用相同的 vimrc,其中一些安装了 fugitive.vim,而另一些没有。我喜欢在状态行中包含fugitive#statusline(),但在没有安装插件的机器上,这会引发错误。
有没有办法在调用set statusline 之前检查这个函数是否存在?我试过使用existsy,但由于某种原因它不起作用(加载顺序?)
if exists("*fugitive#statusline")
set statusline=%<\ %f\ %{fugitive#statusline()} ... (other stuff)
endif
我还尝试通过在命令前加上 silent! 来消除错误,但这似乎也不起作用。
【问题讨论】: