(Click here to skip to the solution below, including a screenshot of an example file, and the complete syntax definition and color scheme files I created, or continue reading to get more background on this issue.)
I’ve created my own txt file editing syntax to allow me to use various symbol strings to color code my text files in Sublime Text 3. However, I can’t seem to figure out how to set up the scopes to have them properly able to pop in and out within the context of one another.
For example, if I’m using scope A, which is triggered/escaped by typing “==”, I want to be able to add a few words in scope B (which is triggered/escaped using “++”) while scope A is on the stack, yet I also want to be able to do the opposite, and have the ability to add a few words using scope A while scope B is on the stack. And I have 6 scopes in total that I want to be able to pop in and out of within the context of any of the others. How do I need to set up the scope definitions in the sublime-syntax file in order to achieve this?
Here are some examples to illustrate this concept and what I hope to achieve a bit more clearly:
==teal-colored text from use of double equal sign --red text from double hyphen-- back to the teal text, ++green text scope from use of double plus sign --red text scope again-- back to green text++ back to teal.==
++green text ==teal text== green text --red text yellow text “orange text” yellow text red text-- green text++
(and this last one might be a stretch to accomplish, or may not even be possible)
yellow text --red text ++green text yellow text green text++ red text-- yellow text no scope applied, default/plain white text.
Basically, the last example shows a second instance of the yellow text scope being pushed onto the stack on top of the --red— and ++green++ which are pushed on top of the first instance of the yellow scope, and the exiting of the second instance of the yellow scope still leaves the first instance on the stack under the --red-- and ++green++ scope.
Hopefully there is some way to achieve this. Really grateful for any help anyone can give me on how to set up the scopes to make it work.
Also, if necessary, I could change my scope triggering/escaping to not use the same symbol strings for both entry/on and exit/off - to use something like == and /==, ++ and /++, – and /–, etc. so they all have an exit/escape that is different from the entry. But ideally, it would look best being able to use the same symbol strings for both on and off.
Thank you!