1

I've added this line to my vimrc file in order to be able to open a link with the command 'gx':

let g:netrw_browsex_viewer = 'firefox'

Unfortunately the only thing that happens is that a tiny DOS window flashes on the screen.

Advice very welcome.

GilF

user2962912
  • 69
  • 1
  • 6
  • Check out [this](http://stackoverflow.com/q/9458294/778118) and [this](http://vim.wikia.com/wiki/Open_a_web-browser_with_the_URL_in_the_current_line). – jahroy Apr 26 '14 at 21:15
  • thanks jahroy, The first link contains the instruction that I based my initial action on (ie: setting g:netrw_browsex_viewer to the browser of choice (in this case Firefox). Granted that both links detail a – user2962912 Apr 27 '14 at 17:47
  • - number of relevant scripts, but before testing those I was wondering whether there was a simpler option of amending any existing netrw config variables? The help file for netrw seems to indicate that this is possible, by either amending the http protocol variable - `g:netrw_http_cmd` - or amending the browser variable - `g:netrw_browsex_viewer`. Thanks, GilF – user2962912 Apr 27 '14 at 17:55
  • possible duplicate of [gvim windows netrw filehandler html elinks configuration](http://stackoverflow.com/questions/26632841/gvim-windows-netrw-filehandler-html-elinks-configuration) – idbrii Nov 06 '14 at 16:48
  • Duplicate: [gvim windows netrw filehandler html elinks configuration](http://stackoverflow.com/questions/26632841/gvim-windows-netrw-filehandler-html-elinks-configuration). Instead of a new question, you could have rephrased or deleted this one. – idbrii Nov 06 '14 at 17:03

2 Answers2

2

On windows7, put the batch file expl2.cmd in your vim path.

In vimrc put

:let netrw_browsex_viewer='expl2.cmd'

In gvim use gx on cfile to launch explorer.exe, it will launch correct viewer, e.g. powerpoint,firefox,chrome. Notes: The second line converts forward slashes to backslashes. If you have spaces in your filename, vim won't expand cfile.

c:> cat expl2.cmd

set file=%1
set file=%file:/=\%
start explorer.exe /n,/e,/root,%file%
mosh
  • 1,402
  • 15
  • 16
0

I think firefox is not exists in your PATH variable. To set it:

On the bottom of the Start menu type in env, then select one of the elemets in the list to set up environment variables. (if you are an administrator then select the system variables, otherwise the other opinion) Search for the PATH variable, then double click on it to set it's value. Add the path of the firefox.exe to the end of the string with a semicolon before it, for example: ;C:\Program Files\firefox\

It should work now.

bimlas
  • 2,359
  • 1
  • 21
  • 29
  • Sorry -to clarify I'm trying to open locally saved html files, not URLs. I commented out the line in my .vimrc, and netrw now opens them with firefox. I did not amend the PATH variable. Posted a clearer request here: [edit] http://stackoverflow.com/questions/26632841/gvim-windows-netrw-filehandler-html-elinks-configuration – user2962912 Oct 29 '14 at 14:58