简体   繁体   English

在vimrc和gvimrc中具有相同的“ au FilterWritePost”-在vim中都被调用?

[英]Having the same “au FilterWritePost” in vimrc and gvimrc - are both called in vim?

如果我有au FilterWritePost * do_something.vimrcau FilterWritePost * do_something2.gvimrc和开放gVim的,做这个活动,都调用,或是否.gvimrc定义“覆盖” .vimrc里定义(do_something2改为只do_something,或两者)?

Yes they will. 是他们会。 You can prevent this from happening by typing it this way 您可以通过这样输入来防止这种情况的发生

au! FilterWritePost * do_something2

the ! tells the autocommand to replace any other autocommand with the same FilterWritePost signature. 告诉自动命令用相同的FilterWritePost签名替换任何其他自动命令。 If you fire up gvim the .vimrc will fire off first then the .gvimrc so your autocommand in the .vimrc will be replaced with the version in your .gvimrc 如果启动gvim,则首先会启动.vimrc,然后将启动.gvimrc,因此.vimrc中的自动命令将替换为.gvimrc中的版本

In addition to jackerran answer: use autocommand groups: 除了jackerran答案:使用自动命令组:

" Name may be any, but it should not be equal to any of events name. "
" Case is ignored "
augroup ThisDoesSomething
    " Wipe out every event from this group "
    autocmd!
    autocmd! FilterWritePost * do_something
augroup END

This is safe to be put both into vimrc and gvimrc at one time: au! 可以一次性将它同时放入vimrc和gvimrc中: au! will clear duplicates if they occur. 如果出现重复项,则会清除重复项。

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

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