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
  • 相关阅读:
    作业2
    实验12——指针的基础应用2
    实验11——指针的基础应用
    实验十——一维数组的定义及引用
    实验九——基本数据类型存储及应用总结
    实验八--函数定义及调用总结
    实验七——函数定义及调用总结
    实验六——循环结构程序练习总结
    实验五——循环结构学习总结
    实验三——for 语句及分支结构else-if
  • 原文地址:https://www.cnblogs.com/tshell/p/2752785.html
Copyright © 2011-2022 走看看