sponsor Vim development Vim logo Vim Book Ad

basic Tip #1315: netrw x command

 tip karma   Rating 0/2, Viewed by 1123 

Read and edit this tip on the Vim tip wiki. The wiki may have a more recent version of this tip.

created:   August 24, 2006 14:25      complexity:   basic
author:   Steve dugaro      as of Vim:  

> Ive started using netrw extensively with vim7.
> Im having one issue when trying to override the x command.
> Essentially, i copied $VIMRUNTIME/autoload/netrwFileHandlers.vim
> into my .vim/plugins (and /autoload) directory expecting to
> override any functions defined in $VIMRUNTIME with my own.
> for instance, i attempt to handle .pdfs with acroread instead of gs.
> the problem is, BOTH file handlers are called.
> first the .pdf is launched with gs, then again with acroread.
> ive setup c++ filehandlers to checkout files from version control
> when the cursor is on that file and i hit 'x'. this works... however as
> above, kwrite is launched automatically prior to the checkout
> setting
> let g:netrw_browsex_viewer = '-'
> in my .vimrc does not appear to have any effect
> as the kfmclient exec is still called.

So after copying all of the $VIMRUNTIME/autoload/netrw.vim
to my .vim/autoload, $VIMRUTIME/autoload/netrwFileHandlers.vim
to my .vim/plugin and $VIMRUNTIME/plugin/netrwPlugin.vim
to my .vim/plugin directory and hacking around netrw.vim a bit i noticed
bad logic in the branch tests if g:netrw_browserx_viewer == '-' is set (which
according to the documentation is supposed to use netrwFileHandler()
from netrwFileHandlers.vim instead of the os's run dialog... in my case
kfmclient exec)

if exists("g:netrw_browserx_viewer) && executable(g:netrw_browsex_viewer)
  "(does not even get here to test if g:netrw_browserx_viewer is set in .vimrc)
   if g:netrw_browserx_viewer == '-'

This fails because there is no executable named "-"
if exists("g:netrw_browserx_viewer) && executable(g:netrw_browsex_viewer)
if exists("g:netrw_browserx_viewer)
comment out the line just prior to the && and problem solved.

 rate this tip  Life Changing Helpful Unfulfilling 

<< Real "open-in-tabs" context menu for Vim 7.0 Win32 | Easy visual commenting - Navigating visual selections with '< and '> >>

Additional Notes

ludvig .dot. ericson at gmail dot com, September 2, 2006 18:44
It's confusing how browsex and browserx are used interchangeably though.
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
Sponsored by Web Concept Group Inc. SourceForge.net Logo