Thursday, October 18, 2012

RE: Exec Web Browser

...
> > 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

No comments: