简体   繁体   English

如何防止老版本的vim插件覆盖?

[英]How can i prevent my vim plugins being overridden by older ones?

I have installed MacVim via homebrew, and pathogen via downloading the pathogen.vim file to my ~/.vim/autoload directory. 我已经通过自制软件安装了MacVim,并通过将病原体~/.vim/autoload文件下载到我的~/.vim/autoload目录中来安装了病原体。 I have got cloned the vim-perl plugin into ~/.vim/bundle directory. 我已经将vim-perl插件克隆到~/.vim/bundle目录中。

However, when i open a perl file, it uses the syntax highlighting from the perl.vim file included with MacVimand not my downloaded plugin. 但是,当我打开一个perl文件时,它使用perl.vim随附的perl.vim文件中的语法高亮显示,而不是我下载的插件。 This is the output of :scriptnames . 这是:scriptnames的输出。 Note all the MacVim supplied plugins are there and I think the perl ones listed last overwrite my downloaded plugin: 请注意,所有MacVim提供的插件都在那里,我认为最后列出的perl插件会覆盖我下载的插件:

1: /usr/local/Cellar/macvim/7.4-73/MacVim.app/Contents/Resources/vim/vimrc
2: ~/.vimrc
3: ~/.vim/autoload/pathogen.vim
4: /usr/local/Cellar/macvim/7.4-73/MacVim.app/Contents/Resources/vim/runtime/ftoff.vim
5: /usr/local/Cellar/macvim/7.4-73/MacVim.app/Contents/Resources/vim/runtime/syntax/syntax.vim
6: /usr/local/Cellar/macvim/7.4-73/MacVim.app/Contents/Resources/vim/runtime/syntax/synload.vim
7: /usr/local/Cellar/macvim/7.4-73/MacVim.app/Contents/Resources/vim/runtime/syntax/syncolor.vim
8: /usr/local/Cellar/macvim/7.4-73/MacVim.app/Contents/Resources/vim/runtime/filetype.vim
9: ~/.vim/bundle/vim-javascript/ftdetect/javascript.vim
10: ~/.vim/bundle/vim-perl/ftdetect/mason-in-html.vim
11: ~/.vim/bundle/vim-perl/ftdetect/perl11.vim
12: ~/.vim/bundle/vim-ruby/ftdetect/ruby.vim
13: ~/.vim/bundle/vim-scala/ftdetect/scala.vim
14: /usr/local/Cellar/macvim/7.4-73/MacVim.app/Contents/Resources/vim/runtime/menu.vim
15: /usr/local/Cellar/macvim/7.4-73/MacVim.app/Contents/Resources/vim/runtime/autoload/paste.vim
16: /usr/local/Cellar/macvim/7.4-73/MacVim.app/Contents/Resources/vim/runtime/ftplugin.vim
17: /usr/local/Cellar/macvim/7.4-73/MacVim.app/Contents/Resources/vim/runtime/indent.vim
18: ~/.vim/colors/default.vim
19: ~/.vim/bundle/vim-scala/plugin/scala.vim
20: /usr/local/Cellar/macvim/7.4-73/MacVim.app/Contents/Resources/vim/runtime/plugin/getscriptPlugin.vim
21: /usr/local/Cellar/macvim/7.4-73/MacVim.app/Contents/Resources/vim/runtime/plugin/gzip.vim
22: /usr/local/Cellar/macvim/7.4-73/MacVim.app/Contents/Resources/vim/runtime/plugin/matchparen.vim
23: /usr/local/Cellar/macvim/7.4-73/MacVim.app/Contents/Resources/vim/runtime/plugin/netrwPlugin.vim
24: /usr/local/Cellar/macvim/7.4-73/MacVim.app/Contents/Resources/vim/runtime/plugin/rrhelper.vim
25: /usr/local/Cellar/macvim/7.4-73/MacVim.app/Contents/Resources/vim/runtime/plugin/spellfile.vim
26: /usr/local/Cellar/macvim/7.4-73/MacVim.app/Contents/Resources/vim/runtime/plugin/tarPlugin.vim
27: /usr/local/Cellar/macvim/7.4-73/MacVim.app/Contents/Resources/vim/runtime/plugin/tohtml.vim
28: /usr/local/Cellar/macvim/7.4-73/MacVim.app/Contents/Resources/vim/runtime/plugin/vimballPlugin.vim
29: /usr/local/Cellar/macvim/7.4-73/MacVim.app/Contents/Resources/vim/runtime/plugin/zipPlugin.vim
30: ~/.vim/bundle/vim-scala/after/plugin/help.vim
31: /usr/local/Cellar/macvim/7.4-73/MacVim.app/Contents/Resources/vim/gvimrc
32: ~/.vim/bundle/vim-perl/syntax/perl.vim
33: ~/.vim/bundle/vim-perl/syntax/pod.vim
34: /usr/local/Cellar/macvim/7.4-73/MacVim.app/Contents/Resources/vim/runtime/syntax/pod.vim
35: /usr/local/Cellar/macvim/7.4-73/MacVim.app/Contents/Resources/vim/runtime/syntax/perl.vim
36: ~/.vim/bundle/vim-perl/ftplugin/perl.vim
37: /usr/local/Cellar/macvim/7.4-73/MacVim.app/Contents/Resources/vim/runtime/ftplugin/perl.vim
38: ~/.vim/bundle/vim-perl/indent/perl.vim
39: /usr/local/Cellar/macvim/7.4-73/MacVim.app/Contents/Resources/vim/runtime/indent/perl.vim

Here is my ~/.vimrc file 这是我的~/.vimrc文件

set shell=/bin/sh

call pathogen#infect()

filetype off
syntax on
filetype plugin indent on

If I :so ~/.vim/bundle/vim-perl/syntax/perl.vim then the file syntax highlights correctly. 如果我:so ~/.vim/bundle/vim-perl/syntax/perl.vim则文件语法正确突出显示。

How can I prevent the MacVim bundled ones overriding? 如何防止MacVim捆绑包覆盖?

The inclusion guard ( if exists("b:current_syntax") ) should prevent the default Perl syntax script from having any effect (after your custom one has been sourced). 包含防护( if exists("b:current_syntax")if exists("b:current_syntax") )应该防止默认的Perl语法脚本生效(在获得自定义脚本之后)。

As a workaround, you could move your own script from ~/.vim/bundle/vim-perl/syntax/perl.vim to ~/.vim/bundle/vim-perl/after/syntax/perl.vim , or alternatively create a ~/.vim/after/syntax/perl.vim script with 解决方法是,您可以将自己的脚本从~/.vim/bundle/vim-perl/syntax/perl.vim移至~/.vim/bundle/vim-perl/after/syntax/perl.vim ,或者创建~/.vim/after/syntax/perl.vim脚本,其中

so ~/.vim/bundle/vim-perl/syntax/perl.vim

in it. 在里面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM