11

On some machines I'm using an external executable to format text (it's named 'par'). Therefore I'd like to detect if the executable is installed.

Edit: I just want to detect if the executable is available in my .vimrc itself. So I prefer internal functions over external utils like 'which'. Prince Goulash's solution is already very helpful and I'm going with it, despite I'd prefer finding the exact path. Thanks.

urso
  • 924
  • 1
  • 7
  • 17

3 Answers3

17

You can use the vimscript function executable(), which returns 1 if its argument exists and is executable, and 0 otherwise. It doesn't return the path of the file, though. See help executable for more info.

Prince Goulash
  • 15,295
  • 2
  • 46
  • 47
4

In linux, I'd use which:

:!which par

If you want to put it into the file, try this:

:r !which par

Edit: Actually, hash might be the better tool to use.

Community
  • 1
  • 1
gpojd
  • 22,558
  • 8
  • 42
  • 71
0

in unix...

whereis par

should return a path, if it is executable by the current user

diagonalbatman
  • 17,340
  • 3
  • 31
  • 31