I have large amount of C code and a large portion of the code is commented out and/or #if 0. When I use the % key to match the open and close brackets of if-else, it matches the commented out code too.
Is there a way or a vim plugin that would not consider the commented out or #if 0 code, while matching brackets.
Currently I am using snipMate and omniComplete vim plugins.
As mentioned by david, the matchit plugin is able to skip over comments. However, the syntax group that the C syntax script defines for #if 0
is not configured in the plugin. Create a file ~/.vim/after/ftplugin/c.vim
and put the following into it:
" Make the matchit plugin also skip over sections commented out via #if 0.
let b:match_skip .= '\|cCppOut2'
The matchit plugin (included with vim but not enabled) should do this by default for commented out code. Pretty sure it won't work with #if 0
code. Check out :h matchit
and :h match_skip
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With