How to find the location of the vim executable?

1,202 views
Skip to first unread message

Sean

unread,
Dec 1, 2009, 2:33:19 PM12/1/09
to vim_use
Hi,

Is it possible to detect the vim executable on which I am running?

The purpose is to drop wget.exe to the same directory as gvim.exe
and vimrun.exe under Windows. With three executables, I can make
a simplest "plug and play" CLOUD input method, VimIM, on Windows.

As of now, I ask users to drop wget.exe to the plugin directory, and
I can detect it by using something like =>
s:path=expand("<sfile>:p:h")."/"

Thanks

Sean



Tony Mechelynck

unread,
Jan 2, 2010, 2:06:59 AM1/2/10
to vim...@googlegroups.com, Sean

IIUC, Vim can find executables and shared libraries found:
- on Windows, in the $VIMRUNTIME directory (I think). On Windows, this
directory usually contains the vim executable(s); Vim-related utilities
are placed either in the same directory or in some of its
sub-directories (e.g. $VIMRUNTIME/xxd/xxd.exe).
- on any platform (including Windows), programs can also be found
anywhere in the $PATH (of this I am sure).

On Windows, this may depend on how Vim was installed, but often it is
something like "C:\Program Files\vim\vim72" where "Program Files" may be
different in non-English-language versions of Windows, and "vim72" is
for the current release 7.2 (stable).

On Unix-like platforms (including Cygwin), the vim executable(s) will
usually be in the $PATH; by default in /usr/local/bin if you compile
them yourself, but often in /usr/bin and/or /bin and/or /usr/X11R6/bin
etc. if installed as part of a software distribution. However any
executable anywhere in the $PATH will be found so the exact location of
the wget executable (often /usr/bin) doesn't much matter in this case.

On any platform, trying to execute a program will return a nonzero
status code (ERRORLEVEL in Dos/Windows batch language) if the program
isn't found (typically 127 or maybe 255). This return code can be
examined as the variable v:shell_error, so you can try invoking :!wget
then look at he value of v:shell_error.


Best regards,
Tony.
--
"We had it tough ... I had to get up at 9 o'clock at night, half an
hour before I went to bed, eat a lump of dry poison, work 29 hours down
mill, and when we came home our Dad would kill us, and dance about on
our grave singing Haleleuia ..."
-- Monty Python

Grizzly(Francis Smit)

unread,
Jan 4, 2010, 4:58:52 AM1/4/10
to vim...@googlegroups.com
on unix/linux type this on the command line:
type vim

or
type gvim

the type command should return the path of vim

or
type -p vim

Fuzzy Logic

unread,
Jan 6, 2010, 9:19:56 PM1/6/10
to vim_use
You might also try

which gvim

Reply all
Reply to author
Forward
0 new messages