VimL: Checking if function exists

前端 未结 3 1724
梦如初夏
梦如初夏 2021-02-12 04:16

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

3条回答
  •  别跟我提以往
    2021-02-12 04:46

    The currently selected answer doesn't work for me (using Vim 7.4 / Ubuntu). I believe that's because:

    .vimrc is sourced before any plugins are loaded

    As @ZyX noted this in a comment.

    My preferred method is just to check for the existence of the plugin file. I find this cleaner than writing a separate function in an external file.

    if !empty(glob("path/to/plugin.vim"))
       echo "File exists."
    endif
    

提交回复
热议问题