简体   繁体   English

如何在mac vim的新选项卡中加载插件?

[英]How to load plugins in the new tab in mac vim?

I'm using macvim to code rails project. 我正在使用macvim来编写rails项目。

I used some plugins, which is specific to rails(like vim-rails) and will be loaded only in a rails' app folder. 我使用了一些特定于rails(例如vim-rails)的插件,并且只能在rails的app文件夹中加载。

After I entered a rails's folder, I run mvim and everything goes fine. 在我输入rails的文件夹后,我运行mvim,一切都很顺利。

However, when I use command + T to open a new tab. 但是,当我使用command + T打开一个新选项卡时。 the function of those plugins disabled..seems they are not loaded.. 这些插件的功能已禁用..似乎它们未加载..

How to load them when I open a new tab? 打开新标签时如何加载它们?

If these plugins use the similar code to that one fugitive does, then putting something like 如果这些插件使用类似于一个逃犯的代码,那么就像这样

augroup LaunchFugitiveForAllBuffers
    autocmd!
    autocmd BufNew :doautocmd fugitive BufRead .
augroup END

(replace fugitive with actual event group name [1]). (用实际事件组名称替换fugitive [1])。 You can find this name by either grepping plugin files for BufRead (note: case does not really matter) or walking through the output of au BufRead like I did (there should not be many items). 你可以通过BufRead插件文件找到这个名字(注意:case并不重要)或者像我一样au BufRead的输出(应该没有很多项)。 Note that things may be more complicated: for example your plugins attach to Filetype event and changing the above to doautocmd fugitive Filetype ruby may not help. 请注意,事情可能会更复杂:例如,您的插件附加到Filetype事件,并将上面的更改为doautocmd fugitive Filetype ruby可能没有帮助。 Also note that you can purge out word fugitive at all leaving just a space, but it is potentially destructive operation and can be used only for testing (potentially very destructive in case of Filetype event and some others). 另请注意,您可以清除单词fugitive ,只留下一个空格,但它可能具有破坏性操作,并且只能用于测试(在Filetype事件和其他一些情况下可能非常具有破坏性)。

[1] Note: event group , not plugin name. [1]注意: 事件组 ,而不是插件名称。 These groups are likely to have the name that is a derivative of plugin name, but they are not forced to be equal to it. 这些组的名称可能是插件名称的衍生物,但它们不会被强制等同于它。

Update : It seems that you need railsPluginDetect group for Tim Pope's rails plugin . 更新 :看起来你需要为Tim Pope的rails插件使用 railsPluginDetect组。 I do not have any rails project so I can't say this for sure, but autocommand looks very similar to fugitive one. 我没有任何rails项目,所以我不能肯定地说,但autocommand看起来非常类似于逃犯。 It is better though that you go to plugin bug tracker and add a request there (do not forget to search for an existing one). 最好的是你去插件bug跟踪器并在那里添加一个请求(不要忘记搜索现有的请求)。

Additional informations may be needed but I think that's because the new tab creates an empty virtual buffer. 可能需要其他信息,但我认为这是因为新选项卡创建了一个空的虚拟缓冲区。

Because your RoR-related plugins only work in a Rails folder and you are not in a Rails folder -- you are probably in ~ , check :pwd to know what the working directory is -- those plugins don't work. 因为你的RoR相关插件只能在Rails文件夹中工作而你不在Rails文件夹中 - 你可能在~ ,检查:pwd知道工作目录是什么 - 那些插件不起作用。

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

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