I have the following code in my ini.vim:
augroup HiParens
autocmd!
autocmd Syntax c :syn match Parens /[(){}]/
autocmd Syntax c :syn match Bracks /[\[\]]/
augroup End
And highlighting is done in ~/.config/nvim/after/ftplugin/c.vim
hi Parens ctermfg=XXX
hi Bracks ctermfg=XXX
The first match /[(){}]/
works as expected.
The second seem to do nothing.
Yet this is the way I understand the help page I am supposed to do this.
I found somewhere else here on SE a suggestion about doing exactly this escaping but can't find the link anymore.
I'm a bit surprised, for I would think such escaping would be pretty logical and I also don't get any Errors when loading a C file.
Does anybody know what I did wrong? Must be a stupid detail failure on my end...
containedin=ALL
to the Bracks statement?/[\[\]]/
actually matches \,[
, and]
. The pattern you want is/[[\]]/
, i.e. only]
needs to be escaped inside a collection.