Nested syntax highlighting in vim

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Nested syntax highlighting in vim

Gua Chung Lim-2
Hi all,

I'm trying to create a syntax for my own mine.vim.
I always highlight [words between square brackets in one line] in red.
What if the mentioned square brackets are nested like ...
[words [inside another brackets]]?
I got red color only the first 3 [, [ and ].
But the color for the last one (]) is still white.
The relevant lines of mine.vim are as followings.
% grep mineRed ~/.vim/syntax/mine.vim
syn region mineRed start=+\[+ skip=+\\\\\|\\'+ end=+\]+ oneline
hi def link mineRed SpecialChar

Actually I don't know much about vim syntax highlighting.
I copied these commands from somewhere else (mostly help.vim).
And I then modified it to suit my needs.

Any input would be highly appreciated. Thanks,

--
Gua Chung Lim
 
"UNIX is basically a simple operating system,
but you have to be a genius to understand the simplicity."
-- Dennis M. Ritchie

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Nested syntax highlighting in vim

Andy Wokula
Am 08.01.2019 um 19:09 schrieb Gua Chung Lim:

> Hi all,
>
> I'm trying to create a syntax for my own mine.vim.
> I always highlight [words between square brackets in one line] in red.
> What if the mentioned square brackets are nested like ...
> [words [inside another brackets]]?
> I got red color only the first 3 [, [ and ].
> But the color for the last one (]) is still white.
> The relevant lines of mine.vim are as followings.
> % grep mineRed ~/.vim/syntax/mine.vim
> syn region mineRed start=+\[+ skip=+\\\\\|\\'+ end=+\]+ oneline
> hi def link mineRed SpecialChar
>
> Actually I don't know much about vim syntax highlighting.
> I copied these commands from somewhere else (mostly help.vim).
> And I then modified it to suit my needs.
>
> Any input would be highly appreciated. Thanks,

" add a contains argument:
syn clear
syn region mineRed start=+\[+ skip=+\\\\\|\\'+ end=+]+ oneline contains=mineRed
hi link mineRed SpecialChar

" the skip argument seems useless, you may want to use it to escape a closing ']' (?):
syn clear
syn region mineRed start=+\[+ skip=+\\[\\\]]+ end=+]+ oneline contains=mineRed
hi link mineRed SpecialChar

(syn clear and hi link only added for demo purposes)

--
Andy

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Nested syntax highlighting in vim

Gua Chung Lim-2
* 'Andy Wokula' via vim_use ([hidden email]) wrote:
> syn region mineRed start=+\[+ skip=+\\[\\\]]+ end=+]+ oneline contains=mineRed
That's it. Although I do not understand much, but I get it done.
Thank you very much,

--
Gua Chung Lim
 
"UNIX is basically a simple operating system,
but you have to be a genius to understand the simplicity."
-- Dennis M. Ritchie

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.