OK, this is a bit over my head. I am trying to make sublime work as it does for Plain Text, but syntax highlight text between quotation marks (bear with me). So far I have poached and shortened the syntax mode for JSON, which works, sorta. Double quotes are fine. What I would love is to also highlight text enclosed by literary quotation marks (left and right are different - #147 and #148, or unicode 201C and 201D, respectively), and I am just not good enough with the regex system used within sublime in order to pull it off. TBH, JSON mode comes with word break indentations I cannot get rid of, and I’d love to simply have a Plain text mode - just with quote highlights.
Does anyone maybe have an example, or could possibly help with this?
Edit for clarification: just referring to syntax highlight, not select, find, or replace.
Syntax defs for quotation marks
lm4711
#1
0 Likes
deathaxe
#2
Depending on whether #147/#148 are hex or decimal the following snippet might need to be tweaked, but it should do what you want.
%YAML 1.2
---
# See http://www.sublimetext.com/docs/syntax.html
name: Plain Text (Quoted)
scope: text.plain.quoted
contexts:
main:
- include: double-quoted-strings
- include: single-quoted-strings
- include: other1-quoted-strings
- include: other2-quoted-strings
double-quoted-strings:
- match: \"
scope: punctuation.definition.string.begin.txt
push: double-quoted-string-body
double-quoted-string-body:
- meta_scope: string.quoted.double.txt
- match: \"
scope: punctuation.definition.string.end.txt
pop: 1
single-quoted-strings:
- match: \"
scope: punctuation.definition.string.begin.txt
push: single-quoted-string-body
single-quoted-string-body:
- meta_scope: string.quoted.single.txt
- match: \"
scope: punctuation.definition.string.end.txt
pop: 1
other1-quoted-strings:
- match: \x{147}
scope: punctuation.definition.string.begin.txt
push: other1-quoted-string-body
other1-quoted-string-body:
- meta_scope: string.quoted.other.txt
- match: \x{148}
scope: punctuation.definition.string.end.txt
pop: 1
other2-quoted-strings:
- match: \x{201C}
scope: punctuation.definition.string.begin.txt
push: other2-quoted-string-body
other2-quoted-string-body:
- meta_scope: string.quoted.other.txt
- match: \x{201D}
scope: punctuation.definition.string.end.txt
pop: 1
1 Like