只有在Vim的启用某些插件和选项的.h和.cpp文件 [英] Enabling certain plugins and options for .h and .cpp files only in Vim

查看:263
本文介绍了只有在Vim的启用某些插件和选项的.h和.cpp文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装delimitMate在Vim的梅开二度完成,但正在运行的所有文件,而不仅仅是h和.cpp文件。 DelimitMate有在缓冲区,所以我需要的东西添加到我的.vimrc,上面写着中的所有文件的缓冲区禁止delimitMate除了h和.cpp文件虽然我不知道该怎么做,禁用本身的选项。

I have delimitMate installed for brace completion in Vim but it is running for all files, not just .h and .cpp files. DelimitMate has an option for disabling itself in the buffer so I need to add something to my .vimrc that says "disable delimitMate in the buffer of all files except for .h and .cpp files" though I have no idea how to do that.

推荐答案

阅读 DelimitMate 在文档:H'b:delimitMate_autoclose 。以下添加到您的的〜/ .vimrc

Reading the DelimitMate documentation at :h 'b:delimitMate_autoclose'. Add the following to your ~/.vimrc:

let g:delimitMate_autoclose = 0
augroup my_delimitmate
  autocmd!
  autocmd FileType cpp let b:delimitMate_autoclose = 1
augroup END

我们的想法是在全球范围内关闭autoclose( G:),并重新打开它特定的缓冲区( B )。

The idea is to turn off autoclose globally (g:) and turn it back on for specific buffers (b:).

而不是的:自动命令:augrou​​p 命令,你可以设置 B:loaded_delimitMate 相应的文件类型插件文件里面。例如以下内容添加到〜/的.vim /后/文件类型插件/ cpp.vim里

Instead of the :autocmd and :augroup commands you can set b:loaded_delimitMate inside the appropriate ftplugin file. Example add the following to ~/.vim/after/ftplugin/cpp.vim:

let b:delimitMate_autoclose = 1

如果你想保持你的的〜/ .vimrc 文件清理或你已经有很多文件类型的特定命令,设置或映射这种方法可能是prefered。

This method might be prefered if you want to keep your ~/.vimrc file clean or you already have many filetype specific commands, settings, or mappings.

请注意:我不使用DelimitMate所以我没有测试任何设置

Note: I do not use DelimitMate so I have not tested any of these settings.

有关更多帮助,请参见:

For more help see:

:h :aug
:h :au
:h FileType
:h 'b:delimitMate_autoclose'
:h delimitMateFileType
:h ftplugin

这篇关于只有在Vim的启用某些插件和选项的.h和.cpp文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆