Exec Web Browser

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Exec Web Browser

Sayth Renshaw
Hi

I have been looking for a way to send a html file to browser to review
it. There is a lot of attempts, there is one here on stackoverflow
http://stackoverflow.com/questions/8708154/open-current-file-in-web-browser-in-vim

Which uses
nmap <silent> <leader>w :exec 'silent !google-chrome % &'

But apparently that isn't working according to responses. I am on
windows and vim.

Is there a way to adapt this or is there a better solution or plugin?

Sayth

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: Exec Web Browser

Gary Johnson-4
On 2012-10-18, Sayth Renshaw wrote:

> Hi
>
> I have been looking for a way to send a html file to browser to review
> it. There is a lot of attempts, there is one here on stackoverflow
> http://stackoverflow.com/questions/8708154/open-current-file-in-web-browser-in-vim
>
> Which uses
> nmap <silent> <leader>w :exec 'silent !google-chrome % &'
>
> But apparently that isn't working according to responses. I am on
> windows and vim.
>
> Is there a way to adapt this or is there a better solution or plugin?

On Windows, the following worked to send a file to Firefox.

    :!start "C:\Program Files\Mozilla Firefox\firefox.exe" %

The following mapping also worked.

    nmap <silent> <leader>w :silent !start "C:\Program Files\Mozilla Firefox\firefox.exe" %<CR>

Beware of responses on stackoverflow.  The quality varies from very
good to horrible.  The ":exec" is not needed in your example above.
Windows executables other than Windows utilities are typically not
found in PATH, so you usually need to specify the full path name.

HTH,
Gary

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: Exec Web Browser

Alessandro Antonello

Hi,
Instead of "!start SOMETHING" you could try simply "!start %". This way Windows will use your default browser.
Not tested.

Em 17/10/2012 20:59, "Gary Johnson" <[hidden email]> escreveu:
On 2012-10-18, Sayth Renshaw wrote:
> Hi
>
> I have been looking for a way to send a html file to browser to review
> it. There is a lot of attempts, there is one here on stackoverflow
> http://stackoverflow.com/questions/8708154/open-current-file-in-web-browser-in-vim
>
> Which uses
> nmap <silent> <leader>w :exec 'silent !google-chrome % &'
>
> But apparently that isn't working according to responses. I am on
> windows and vim.
>
> Is there a way to adapt this or is there a better solution or plugin?

On Windows, the following worked to send a file to Firefox.

    :!start "C:\Program Files\Mozilla Firefox\firefox.exe" %

The following mapping also worked.

    nmap <silent> <leader>w :silent !start "C:\Program Files\Mozilla Firefox\firefox.exe" %<CR>

Beware of responses on stackoverflow.  The quality varies from very
good to horrible.  The ":exec" is not needed in your example above.
Windows executables other than Windows utilities are typically not
found in PATH, so you usually need to specify the full path name.

HTH,
Gary

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

RE: Exec Web Browser

David Fishburn-2
In reply to this post by Gary Johnson-4
...
> > I have been looking for a way to send a html file to browser to review
> > it. There is a lot of attempts, there is one here on stackoverflow
> >
http://stackoverflow.com/questions/8708154/open-current-file-in-web-browser-
in-vim
...
>
> On Windows, the following worked to send a file to Firefox.
>
>     :!start "C:\Program Files\Mozilla Firefox\firefox.exe" %
>
> The following mapping also worked.
>
>     nmap <silent> <leader>w :silent !start "C:\Program Files\Mozilla
Firefox\firefox.exe" %<CR>
>

I use the following two maps (on Windows):


Quite often while editing a file, I want Windows Explorer to be opened
in the directory of the file.
That way I can right click on the file or double click on it.

nnoremap <silent> <C-F5> :if expand("%:p:h") != ""<CR>:!start explorer.exe
%:p:h<CR>:endif<CR><CR>


But, if I "visually" select some data and use the same key mapping as the
above
I specifically want Windows to execute it.  So in your case and along with
what Gary said, let Windows use the default action assigned to the file
association.

vnoremap <silent> <C-F5> :<C-U>let old_reg=@"<cr>gvy:silent!!cmd /cstart
<C-R><C-R>"<CR><CR>:let @"=old_reg<cr>


This way I have only 1 key stroke to remember, though when visually selected
they perform different actions.  The preamble around the call is just to
restore the default Vim registers which I used when executing the command
so that things are returned to how they were before I used the map.

HTH,
Dave


--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: Exec Web Browser

Benjamin Fritz
In reply to this post by Sayth Renshaw
On Wednesday, October 17, 2012 6:26:48 PM UTC-5, flebber wrote:

> Hi
>
>
>
> I have been looking for a way to send a html file to browser to review
>
> it. There is a lot of attempts, there is one here on stackoverflow
>
> http://stackoverflow.com/questions/8708154/open-current-file-in-web-browser-in-vim
>
>
>
> Which uses
>
> nmap <silent> <leader>w :exec 'silent !google-chrome % &'
>
>
>
> But apparently that isn't working according to responses. I am on
>
> windows and vim.
>
>
>
> Is there a way to adapt this or is there a better solution or plugin?
>

There is a wiki page, but there's a lot of content there that needs a lot of work.

http://vim.wikia.com/wiki/Preview_current_HTML_file

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: Exec Web Browser

tyru-2
In reply to this post by Sayth Renshaw
Hi Sayth Renshaw

Try this script:
http://www.vim.org/scripts/script.php?script_id=3133

On Thu, Oct 18, 2012 at 8:26 AM, Sayth Renshaw <[hidden email]> wrote:

> Hi
>
> I have been looking for a way to send a html file to browser to review
> it. There is a lot of attempts, there is one here on stackoverflow
> http://stackoverflow.com/questions/8708154/open-current-file-in-web-browser-in-vim
>
> Which uses
> nmap <silent> <leader>w :exec 'silent !google-chrome % &'
>
> But apparently that isn't working according to responses. I am on
> windows and vim.
>
> Is there a way to adapt this or is there a better solution or plugin?
>
> Sayth
>
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: Exec Web Browser

Bill Chan
On 10/19/2012 8:35 AM, tyru wrote:

> Hi Sayth Renshaw
>
> Try this script:
> http://www.vim.org/scripts/script.php?script_id=3133
>
> On Thu, Oct 18, 2012 at 8:26 AM, Sayth Renshaw <[hidden email]> wrote:
>> Hi
>>
>> I have been looking for a way to send a html file to browser to review
>> it. There is a lot of attempts, there is one here on stackoverflow
>> http://stackoverflow.com/questions/8708154/open-current-file-in-web-browser-in-vim
>>
>> Which uses
>> nmap <silent> <leader>w :exec 'silent !google-chrome % &'
>>
>> But apparently that isn't working according to responses. I am on
>> windows and vim.
>>
>> Is there a way to adapt this or is there a better solution or plugin?
>>
>> Sayth
>>
>> --
>> You received this message from the "vim_use" maillist.
>> Do not top-post! Type your reply below the text you are replying to.
>> For more information, visit http://www.vim.org/maillist.php
>

Hi Sayth,

This works for me on my windows 7 machine:
nnoremap <silent> <leader>w :!start "C:\Program Files (x86)\Mozilla
Firefox\firefox.exe" file://%:p<CR>

Regards,
Bill

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php