Registration of Vim executable on Windows

34 views
Skip to first unread message

Anton Shepelev

unread,
Aug 3, 2020, 8:11:09 AM8/3/20
to vim...@googlegroups.com
Hello, all

How are the Vim executables regitered on Windows so that
they are always available from the command prompt even
though no environment variable seems to contain their path? On
my PC, for example, Vim's executables are installed at

C:\Program Files\Vim\vim80

but

set | grep vim

does show anything. How does Windows locate vim.exe,
gvim.exe when I invoke them from the command line?

--
Please, do not forward replies to the list to my e-mail.

Christian Brabandt

unread,
Aug 3, 2020, 8:13:05 AM8/3/20
to vim...@googlegroups.com

On Mo, 03 Aug 2020, Anton Shepelev wrote:

> Hello, all
>
> How are the Vim executables regitered on Windows so that
> they are always available from the command prompt even
> though no environment variable seems to contain their path? On
> my PC, for example, Vim's executables are installed at
>
> C:\Program Files\Vim\vim80
>
> but
>
> set | grep vim
>
> does show anything. How does Windows locate vim.exe,
> gvim.exe when I invoke them from the command line?

This is done using the %PATH% environment variable, see e.g. the
wikipedia article: https://en.wikipedia.org/wiki/PATH_(variable)

Best,
Christian
--
Toni fällt in den See wird aber gerettet. Der Retter fragt ihn:
"Warum bist du denn nicht geschwommen?" Toni: "Aber da steht doch ein
Schild - Schwimmen Verboten!"

Anton Shepelev

unread,
Aug 3, 2020, 8:15:12 AM8/3/20
to vim...@googlegroups.com
I wrote:

> On my PC, for example, Vim's executables are installed at
>
> C:\Program Files\Vim\vim80
>
> but
>
> set | grep vim
>
> does show anything.

* does not show anything.

Tony Mechelynck

unread,
Aug 3, 2020, 11:52:37 AM8/3/20
to vim_use
On Mon, Aug 3, 2020 at 2:15 PM Anton Shepelev <anto...@gmail.com> wrote:
>
> I wrote:
>
> > On my PC, for example, Vim's executables are installed at
> >
> > C:\Program Files\Vim\vim80
> >
> > but
> >
> > set | grep vim
> >
> > does show anything.
>
> * does not show anything.

At the command prompt,
echo %PATH%

should display a list of directories, one of which contains the Vim
executables. All executables you invoke at the command prompt are
searched in that same list, and the first one found gets executed. (If
your comand interpreter includes code for built-in commands, those
ones are looked-up first, and executed if a match is found, unless you
specify the .exe, .com, or .bat extension.)

Best regards,
Tony.

Anton Shepelev

unread,
Aug 3, 2020, 1:31:57 PM8/3/20
to vim...@googlegroups.com
Tony Mechelynck to Anton Shepelev:

> > On my PC, for example, Vim's executables are installed
> > at
> >
> > C:\Program Files\Vim\vim80
> >
> > but
> >
> > set | grep vim
> >
> > does [not] show anything.
>
> At the command prompt,
> echo %PATH%
>
> should display a list of directories, one of which
> contains the Vim executables.

The `set' command, invoked without parameters, lists all the
available environment variables with their values, so my
command `set | grep vim' should have found `vim' too. Here
is my complete output of `echo %PATH%':

C:\MinGW\bin\
D:\PROGRAMS\TCC\
C:\WINDOWS\system32
C:\WINDOWS
C:\WINDOWS\System32\Wbem
D:\BIN\
D:\PROGRAMS\GRAPHVIZ\bin\
C:\Program Files\gs\gs9.10\lib\
C:\Program Files\gs\gs9.10\bin\
D:\PROGRAMS\FPC\bin\i386-Win32
C:\Program Files\GtkSharp\2.12\bin
C:\Program Files\Subversion\bin
C:\Program Files\Pandoc\

and the only instance of gvim.exe on my entire PC is:

C:\Program Files\Vim\vim80\gvim.exe

Yet I can start gvim from the command line in any
directory...

Christian Brabandt

unread,
Aug 3, 2020, 1:50:14 PM8/3/20
to vim...@googlegroups.com

On Mo, 03 Aug 2020, Anton Shepelev wrote:

> Tony Mechelynck to Anton Shepelev:
>
> > > On my PC, for example, Vim's executables are installed
> > > at
> > >
> > > C:\Program Files\Vim\vim80
> > >
> > > but
> > >
> > > set | grep vim
> > >
> > > does [not] show anything.
> >
> > At the command prompt,
> > echo %PATH%
> >
> > should display a list of directories, one of which
> > contains the Vim executables.

You can also use the path command

>
> The `set' command, invoked without parameters, lists all the
> available environment variables with their values, so my
> command `set | grep vim' should have found `vim' too. Here
> is my complete output of `echo %PATH%':
>
> C:\MinGW\bin\
> D:\PROGRAMS\TCC\
> C:\WINDOWS\system32
> C:\WINDOWS
> C:\WINDOWS\System32\Wbem
> D:\BIN\
> D:\PROGRAMS\GRAPHVIZ\bin\
> C:\Program Files\gs\gs9.10\lib\
> C:\Program Files\gs\gs9.10\bin\
> D:\PROGRAMS\FPC\bin\i386-Win32
> C:\Program Files\GtkSharp\2.12\bin
> C:\Program Files\Subversion\bin
> C:\Program Files\Pandoc\
>
> and the only instance of gvim.exe on my entire PC is:
>
> C:\Program Files\Vim\vim80\gvim.exe
>
> Yet I can start gvim from the command line in any
> directory...

You can or you cannot? I believe the vim installer adds a vim.bat or
gvim.bat file to C:\windows\system32

Best,
Christian
--
Barmen (V.)
Beschreibt den Versuch eines Betrunkenen, sich bei jemandem lieb Kind
zu machen.
-- Douglas Adams, John Lloyd, Sven Böttcher ("Der tiefere Sinn des Labenz")

Gabriele Fava

unread,
Aug 3, 2020, 2:48:45 PM8/3/20
to 'Matthias Guenther' via vim_use
On 03/08/2020 19.50, Christian Brabandt wrote:
> You can or you cannot? I believe the vim installer adds a vim.bat or
> gvim.bat file to C:\windows\system32

It adds various .bat files, among which vim.bat and gvim.bat, to
C:\Windows, which by default is included in the %PATH%.

It is indeed quite unusual and if you're not aware or have forgotten
about the files it's not very easy to find out what's going on.

However the installer mentions them clearly (currently the option is
called "Create .bat files", with a description "Create .bat files for
Vim variants in the Windows directory for command line use"), and indeed
they are not added by the default installation, you have to toggle the
option manually or choose the "Full" installation.

Older installers though did not have the description, so it was harder
to understand what the option did.

And in any case you'll probably forget about the whole thing after a few
months (I did)


Kind regards,

Gabriele

Anton Shepelev

unread,
Aug 3, 2020, 4:30:12 PM8/3/20
to vim...@googlegroups.com
Christian Brabandt to Anton Shepelev:

> > Yet I can start gvim from the command line in any
> > directory...
>
> You can or you cannot? I believe the vim installer adds a
> vim.bat or gvim.bat file to C:\windows\system32

Ah, that explains it. Thank you, Christian.

--
Please, do not forward replies to my e-mail.

Anton Shepelev

unread,
Aug 3, 2020, 4:35:12 PM8/3/20
to vim...@googlegroups.com
Gabriele Fava to Christian Brabandt:

> > I believe the vim installer adds a vim.bat or gvim.bat
> > file to C:\windows\system32
>
> It adds various .bat files, among which vim.bat and
> gvim.bat, to C:\Windows, which by default is included in
> the %PATH%.
>
> It is indeed quite unusual and if you're not aware or have
> forgotten about the files it's not very easy to find out
> what's going on.
>
> However the installer mentions them clearly (currently the
> option is called "Create .bat files", with a description
> "Create .bat files for Vim variants in the Windows
> directory for command line use"), and indeed they are not
> added by the default installation, you have to toggle the
> option manually or choose the "Full" installation.

Indeed. I thought those .bat files to were supplementary
scripts for using Vim non-interactively and did not care a
carrot about reading the detailed description. Thank you for
the explanation, Gabriele. I should like to propose a more
descriptive name for that installer item but cannot come up
with one sufficiently short.

--
Please, do not forward replies to my e-mail.

Gabriele Fava

unread,
Aug 4, 2020, 12:27:43 PM8/4/20
to 'Matthias Guenther' via vim_use
On 03/08/2020 22.34, Anton Shepelev wrote:
> I should like to propose a more
> descriptive name for that installer item but cannot come up
> with one sufficiently short.

I dug through vim's history and I found out that these batch files were
introduced along with the nsis instaler in vim 6.0
(https://ftp.vim.org/pub/vim/pc/gvim60.exe), and the option's
description stayed "Create .bat files for command line use" from that
version up to v8.1.0616 when the whole installer was refreshed (and the
current "Create .bat files" string was introduced).

It's not very easy to choose a better name, maybe "Add .bat files in
%SystemRoot%" might be more clear (hopefully with %SystemRoot% expanded
to its actual value - usually C:\Windows).
And the description maybe might just say, since there's only so much
space for it, something like "...so that typing 'vim', 'gvim' etc. will
launch vim from any command prompt"

Anton Shepelev

unread,
Aug 6, 2020, 5:18:51 PM8/6/20
to vim...@googlegroups.com
Gabriele Fava:

> I dug through vim's history and I found out that
> these batch files were introduced along with the
> nsis instaler in vim 6.0
> (https://ftp.vim.org/pub/vim/pc/gvim60.exe),
> and the option's description stayed "Create .bat
> files for command line use" from that version up
> to v8.1.0616 when the whole installer was re-
> freshed (and the current "Create .bat files"
> string was introduced).

Thanks for the reasearch, Gabriele!

> It's not very easy to choose a better name, maybe
> "Add .bat files in %SystemRoot%" might be more
> clear (hopefully with %SystemRoot% expanded to its
> actual value - usually C:\Windows). And the de-
> scription maybe might just say, since there's only
> so much space for it, something like "...so that
> typing 'vim', 'gvim' etc. will launch vim from any
> command prompt"

It is a hard problem in English compostion, indeed.
Maybe say something more abstract:

1. Make Vim available on command line
2. Register Vim for command-line invocaton

and let the Description tell the implementation de-
tails, that it means putting .bat files in
C:\Windows ? I for one should prefer it that way,
because this wording would not confuse me.

Gabriele Fava

unread,
Sep 8, 2020, 11:16:02 AM9/8/20
to vim...@googlegroups.com
I apologise for replying so late, I missed your message and then forgot
about the thread

Yes, I agree with you, "Make Vim available on command line" sounds good.

By the way, for the developers, I also noticed that the italian
translation of the option is wrong and very hard to understand (I think
a correct one, for the current descriptions, would be "Crea file .bat"
and "Crea file .bat per varianti di Vim nella directory di Windows, per
utilizzo da riga di comando").


Kind regards,

Gabriele

Christian Brabandt

unread,
Sep 8, 2020, 12:52:09 PM9/8/20
to vim...@googlegroups.com

On Di, 08 Sep 2020, Gabriele Fava wrote:
> By the way, for the developers, I also noticed that the italian
> translation
> of the option is wrong and very hard to understand (I think a correct one,
> for the current descriptions, would be "Crea file .bat" and "Crea file .bat
> per varianti di Vim nella directory di Windows, per utilizzo da riga di
> comando").

Could you please fork and clone the repository to your local workspace,
go to the nsis/lang/ directory, then you can fix the typo in the file
italian.nsi. Then commit your change and push to your fork and create a
PR for the changed file. Thanks!

Best,
Christian
--
Kein Kunde kauft jemals ein Erzeugnis. Er kauft immer das, was das
Erzeugnis für ihn leistet.
-- Peter Drucker

Gabriele

unread,
Sep 8, 2020, 4:56:02 PM9/8/20
to vim...@googlegroups.com
On 08/09/2020 18.51, Christian Brabandt wrote:
> Could you please fork and clone the repository to your local workspace,
> go to the nsis/lang/ directory, then you can fix the typo in the file
> italian.nsi. Then commit your change and push to your fork and create a
> PR for the changed file. Thanks!

Ok, done

Reply all
Reply to author
Forward
0 new messages