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
  • 相关阅读:
    去掉ASP.NET Development Server 中的虚拟路径
    实战 SQL Server 2008 数据库误删除数据的恢复
    人的一生,到底在追求什么?
    每日一记20211215
    CentOS系统配置本地yum源
    mysql修改和查看时区
    依赖报错问题
    没想到MarkText竟然是一款比Typora更简洁优雅的markdown编辑器,完全开源免费!
    免费javascript富文本编辑器 总有一款会适合你!
    90%的人都不知道网页文字被禁止如何复制,教你几招神奇技能就可以免费解决,一定要看完!
  • 原文地址:https://www.cnblogs.com/tshell/p/2752785.html
Copyright © 2011-2022 走看看