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.
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
- What uses more memory in c++? An 2 ints or 2 funct
相关文章
- 如何让 vim 支持 .cshtml 文件的代码高亮
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Auto-save in VIM as you type
- Which is the best way to multiply a large and spar
- Set the z-index value of a jQuery autocomplete inp
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
I think what you are looking for is autocommands. Autocommands can run pieces of vimscript whenever a certain event happens. You can see a list of all possible events by doing
:help autocmd-events
So according to your needs, first you should disable delimitMate in your vimrc. Then, you can put something like this in your vimrc (after you disable delimitMate):
That way, vim will disable delimitMate by default, but it will enable it if the fieltype is cpp. (this includes header files) Of course, more information is available on the
autocmd
command by doing:help :autocmd
Reading the DelimitMate documentation at
:h 'b:delimitMate_autoclose'
. Add the following to your~/.vimrc
:The idea is to turn off autoclose globally (
g:
) and turn it back on for specific buffers (b:
).Instead of the
:autocmd
and:augroup
commands you can setb:loaded_delimitMate
inside the appropriate ftplugin file. Example add the following to~/.vim/after/ftplugin/cpp.vim
: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.Note: I do not use DelimitMate so I have not tested any of these settings.
For more help see: