VimL:检查函数是否存在 [英] VimL: Checking if function exists

查看:29
本文介绍了VimL:检查函数是否存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我正在清理我的 .vimrc 文件以确保它在大多数系统上兼容.

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?

感谢您的帮助!

我有以下几点:

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

推荐答案

使用

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

这篇关于VimL:检查函数是否存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆