GVIM脚本——打开当前文件所在位置

来源:互联网 发布:飞利浦淘宝是真的吗 编辑:程序博客网 时间:2024/06/06 03:48
function OpenFileLocation()if ( expand("%") != "" )execute "!start explorer /select, %" elseexecute "!start explorer /select, %:p:h"endifendfunctionmap gb <ESC>:call OpenFileLocation()<CR>"我的第一个VIM脚本。"功能:当前文件所在位置,同时不阻塞当前窗口。

把这个脚本做成插件也很简单,只要保存成*.vim文件, 再放到插件目录(如:C:\Program Files\Vim\vim73\plugin)下就好了:

"Vim plugin for open current file's loction"Maintainer: ShengFu Li"Last Change: 2012 Sep 30if exists("loaded_OpenFileLocation")  finishendiflet loaded_OpenFileLocation = 1function OpenFileLocation()if ( expand("%") != "" )execute "!start explorer /select, %" elseexecute "!start explorer /select, %:p:h"endifendfunctionmap <leader>o <ESC>:call OpenFileLocation()<CR>