Reputation: 55273
Basically, I want to tell Vim:
PS: Unfortunately I use Windows XP
Upvotes: 12
Views: 29081
Reputation: 3821
On Unix/Linux, use
:! firefox http://localhost/%:p
%:p is the path and filename of the current buffer
Upvotes: 2
Reputation: 84331
You'll need to use a method appropriate to your environment to start the web browser, but you already asked a question about that.
So, use :!start cmd /c ...
, !d:\path\to\firefox ...
or whatever. The important bit: you'll want to use "http://localhost/" . expand("%:t")
as the argument passed to the browser. So, do something like
:exec ":!start cmd /c ... " . "http://localhost/" . expand("%:t")
^- leave a trailing space here
EDIT: A Clarification: expand("%:t")
is a Vim script expression which expands to the last component of the current filename. On Windows this means that if the current filename is C:\a complicated path\to\index.html
, expand("%:t")
will return index.html
.
HTH.
Upvotes: 1
Reputation: 42522
If you are running Vim on windows, then this will work:
:! start http://localhost/index.php
This will use the default browser, if you wanted to start a specific browser then you would need the explicit path to the executable (instead of start).
From the Vim help cmd:
:!{cmd}
Execute {cmd} with the shell. See also the 'shell' and 'shelltype' option.
Obviously, if you are on some other system you just need to use the appopriate command to start the browser on that platform.
Upvotes: 11