vim最新版的winmanager插件可以通过winfileexplorer执行外部程序,例如可以光标选中一个mp3文件,然后shift+s就可以通过系统默认程序打开这个mp3文件,但是只是对Windows有效,Linux下无效,根本原因是winfileexplorer中用的是Windows下的start命令,而Linux下我们要用xdg-open命令,所以只需要在winfileexplorer.vim中添加一行即可,如下加粗所示:

 

"---
" Open file or directory with the corresponding application
" associated by the shell
"
function! s:ShellExecute()
  " Are we on a line with a file name?
  let l = getline(".")
  if l =~ '^"'
    return
  endif

  " Copy window settings to script settings
  let s:sortby=w:sortdirlabel . w:sorttype
  let s:longhelp = w:longhelp
  let s:longlist = w:longlist

  " Get the file name
  let fn=s:GetFullFileName()

  if (has("win32"))
    exec "silent ! start \"\" \"".substitute(fn, "/", "\\", "g")."\""
 
elseif (has("unix")) exec "silent !xdg-open \'".fn."\'"

else if (exists("g:netrw_browsex_viewer")) exec "silent !" . g:netrw_browsex_viewer . " \'".fn."\'" else exec "silent !start \'".fn."\'" endif endif endfunction

另外还发现一个小bug,就是在winmanager窗口和编辑窗口之间用鼠标来回点击时,编辑窗口会莫名其妙地跳行,后来研究发现,原版代码中就有解决办法,只不过注释起来了,找到下面代码:

augroup WinManagerRefresh
        au!
        " Thomas Regner <regner.dievision.de> suggested i use the following
        " autocmds instead, to automatically skip refreshing on [No Files] and
        " such...
        "au BufEnter ^[^\[]* call <SID>RefreshWinManager()
        "au BufDelete ^[^\[]* call <SID>RefreshWinManager("BufDelete")
        au BufEnter * call <SID>RefreshWinManager()
        au BufDelete * call <SID>RefreshWinManager("BufDelete")
    augroup END
换成:
augroup WinManagerRefresh
        au!
        " Thomas Regner <regner.dievision.de> suggested i use the following
        " autocmds instead, to automatically skip refreshing on [No Files] and
        " such...
        au BufEnter ^[^\[]* call <SID>RefreshWinManager()
        au BufDelete ^[^\[]* call <SID>RefreshWinManager("BufDelete")
        "au BufEnter * call <SID>RefreshWinManager()
        "au BufDelete * call <SID>RefreshWinManager("BufDelete")
    augroup END
posted on 2012-11-03 17:02  T_shell  阅读(686)  评论(0编辑  收藏  举报