Open Perl Modules in Vim
在写程序的时候,用到一些perl模块时,经常需要查看这些模块的源代码。以前用的方法是新开一个screen窗口,module_info Module::Name获得模块的路径,然后再在vim里面打开之
久之感觉这样做颇没效率,于是决定写一个vim的函数来实现":Pme Module::Name"即可打开perl模块的功能。
将以下代码写入 .vimrc即可实现这个功能
function! OpenPerlModule(module)
let module_path = system("perldoc -l " . a:module)
if v:shell_error == 1
echo module_path
return
endif
execute "e " . module_path
endfunction
command -nargs=1 Pme call OpenPerlModule(<f-args>)