实在是不喜欢将这种针对某种类型的插件放在plugin目录,因为这样不论打开什么类型的文件都会加载插件。之前c-support就被我扔到ftplugin了,一点问题没有。但perl-support有点小问题(虽然两个插件出自一个作者之手),原因是perl-support中的autocmd用的是BufNewFile,BufRead触发事件,改成FileType就行了。

另外还要将perl-support.vim和ftplugin中的perl.vim合并成perl.vim放于ftplugin下,不能分开放在ftplugin/perl/目录下,某则linux下会找不到template文件

修改perl-support.vim最后几行如下:

   2: if has("autocmd")
   3:  "
   4:  "autocmd 
   5: BufNewFile,BufRead *.pl,*.pm,*.t,*.pod
   6:  "autocmd 
   7: BufNewFile,BufRead *
   8:  autocmd FileType 
   9: *
  10:  
  11: \ if ( &filetype == 'perl' || &filetype == 'pod') 
  12: |
  13:  
  14: \ call 
  15: Perl_CreateMenusDelayed() 
  16: |
  17:  
  18: \ call mmtemplates#core#CreateMaps ( 'g:Perl_Templates', 
  19: g:Perl_MapLeader ) 
  20: |
  21:  
  22: \ endif |
  23:  "
  24:  autocmd BufRead 
  25: *
  26:  
  27: \ if ( &;filetype == 'perl' || &filetype == 'pod') 
  28: |
  29:  
  30: \ call 
  31: Perl_CreateMenusDelayed() 
  32: |
  33:  
  34: \ call mmtemplates#core#CreateMaps ( 'g:Perl_Templates', 
  35: g:Perl_MapLeader ) 
  36: |
  37:  
  38: \ endif 
  39:  "
  40:  autocmd 
  41: BufNewFile,BufRead *.pod setlocal syntax=perl
  42:  autocmd 
  43: BufNewFile,BufRead *.t setlocal 
  44: filetype=perl
  45:  "
  46:  autocmd 
  47: BufNewFile *.pl call 
  48: mmtemplates#core#InsertTemplate(g:Perl_Templates, 'Comments.file description 
  49: pl')
  50:  autocmd BufNewFile *.pm call 
  51: mmtemplates#core#InsertTemplate(g:Perl_Templates, 'Comments.file description 
  52: pm')
  53:  autocmd BufNewFile *.t call 
  54: mmtemplates#core#InsertTemplate(g:Perl_Templates, 'Comments.file description 
  55: t')
  56:  autocmd BufNew *.pl,*.pm,*.t,*.pod call 
  57: Perl_InitializePerlInterface()
  58:  autocmd BufRead 
  59: *.pl,*.pm,*.t,*.pod call Perl_HighlightJumpTargets()
  60:  "
  61:  
  62: " Wrap error descriptions in the quickfix window.
  63:  autocmd BufReadPost 
  64: quickfix setlocal wrap | setlocal linebreak
  65:  
  66: "
  67:  exe 'autocmd BufNewFile,BufReadPost 
  68: '.s:Perl_PerlModuleList.' setlocal foldmethod=expr | setlocal 
  69: foldexpr=Perl_ModuleListFold(v:lnum)'
  70:  
  71: "
  72:  autocmd FileType * if &;filetype =~ '^\(perl\|pod\)$' 
  73: |
  74:  
  75: \ call s:CreateAdditionalMaps() | endif
  76: endif



posted on 2012-12-12 17:03  T_shell  阅读(1115)  评论(0编辑  收藏  举报