Check that an executable exists on the $PATH
When writing a vim plugin interacting with different programs on the server might be necessary. For instance you might want to use ruby
to make a network request or perform some file management. But first, the vim plugin should check to see if the program ruby
exists which can be accomplished with the executable()
vimscript function.
:echo executable('ruby')
1
:echo executable('doesnotexist')
0
This can be used in a condition before running the ruby
command.
if executable('ruby')
system('ruby -e "puts YAML"')
endif
Tweet