Hello. My name is Stupid.
Per good developer practices I’ve read the Fine manual. But either I have missed something or fundamentally I just “don’t get it” —yet. I’m new to this sublime ship, so please, forgive the Stupid. Now down to brass tacks:
Say out of a paragraph of many sentences, I wish to target a specific sentence for highlighting: “The quick brown fox jumps over the lazy dog.”
I can do this from within a myStupid.sublime-syntax file:
- match: “\bThe quick brown fox jumps over the lazy dog.\b”
scope: text.plain.stupid.sentenceOne
I can do this from within a MyStupidSyntax.tmLanguage file and get the same result:
[PackageDev] target_format: plist, ext: tmLanguage
name: Stupid_Syntax
scopeName: text.plain.stupid
fileTypes: [txt]
patterns:
- name: test.plain.stupid.sentenceOne
match: ‘\bThe quick brown fox jumps over the lazy dog.\b’
QUESTION: How does one capture a string literal within a string literal?
- If my “regular expression” is a whole sentence —a specific sentence.
- A word within that sentence is important: “brown” —because we all know foxes are really red.
- How do I capture “brown” without an absolutely horrid regular expression?
I can do this to dissect the sentence, but this opens Pandora’s box, with respect to regular expressions.
This is essentially a word based decomposition of the sentence.
patterns:
- name: test.stupid.sentenceOne
match: ‘(\bThe\b) (\bquick\b) (\bbrown\b) (\bfox\b) (\bjumps\b) (\bover\b) (\bthe\b) (\blazy\b) (\bfox\b)’
captures:
‘1’: {name: wordOne}
‘2’: {name: wordTwo}
‘3’: {name: wordThree}
ETC…
The other option might be to do three capture groups:
begin (The)
middle (quick brown fox jumps over the lazy)
end (dog)
But god almighty. I just want to know whether a specific literal word or sequence of words (phrase), exists within (is a subset of) a specific literal sentence. That is to say,
“brown fox”, exists within “The quick brown fox jumps…”
It seems, that I don’t quite understand nested scopes or scope encapsulation yet with Sublime. I have tried many other things, as is usual to the introvert that does not come to the boards lightly. But I am out of time.
Thank you anyone, anywhere, for any help…
Stupid.