zoukankan      html  css  js  c++  java
  • 对winmanager插件的小改进

    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
  • 相关阅读:
    关于Quartz .NET(V3.0.7)的简要说明
    .NET实现一个简单的IOC容器
    .NET中的控制反转及AutoFac的简单说明
    .NET异步程序设计——async&await
    .NET异步程序设计——任务并行库
    .NET异步程序设计——异步委托
    .NET异步程序设计——概念引入
    关于C#程序的单元测试
    关于Log4Net的使用及配置方式
    基于.net ,使用几种常见的NoSQL数据库
  • 原文地址:https://www.cnblogs.com/tshell/p/2752785.html
Copyright © 2011-2022 走看看