function OpenFileLocation()
if ( expand("%") != "" )
execute "!start explorer /select, %"
else
execute "!start explorer /select, %:p:h"
endif
endfunction
map 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 30
if exists("loaded_OpenFileLocation")
finish
endif
let loaded_OpenFileLocation = 1
function OpenFileLocation()
if ( expand("%") != "" )
execute "!start explorer /select, %"
else
execute "!start explorer /select, %:p:h"
endif
endfunction
map <leader>o <ESC>:call OpenFileLocation()<CR>
本文介绍了一个简单的Vim脚本,该脚本允许用户快速打开当前编辑文件所在的文件夹,并高亮显示该文件,同时不会阻塞Vim窗口。此外,还展示了如何将此功能封装为Vim插件。
809

被折叠的 条评论
为什么被折叠?



