Find executable file path in vim

On some machines, I use an external executable file to format the text (it is called "par"). Therefore, I would like to determine if an executable is installed.

Edit: I just want to determine if an executable is available in my .vimrc. Therefore, I prefer internal functions over external utils like "which". Prince Goulash's solution is already very useful, and I'm going with him, despite the fact that I would prefer to find the exact path. Thank.

+5
source share
3 answers

You can use the vimscript function executable(), which returns 1 if its argument exists and is executable, and 0 otherwise. However, it does not return the file path. See help executablefor more information.

+9
source

In linux, I would use which :

:!which par

If you want to put it in a file, try the following:

:r !which par

Edit: Actually, a hash may be the best tool to use.

+2
source

on unix ...

whereis par

should return a path if it is executed by the current user

0
source

All Articles