[TxMt] Re: Restrict characters in multiline strings

Allan Odgaard mailinglist at textmate.org
Mon Nov 2 01:27:13 UTC 2015


On 2 Nov 2015, at 3:35, Jacob Carlborg wrote:

> Not sure I understand what you mean. The match attribute matches on a 
> single line, not across multiple lines. I need to match code like 
> this:
>
> a = x"abc2
> 13cd";
>
> This is usually handled by using the "begin" and "end" attributes:
>
> {
> begin = 'x"';
> end = '"';
> }
>
> But everything in between the double quotes will match.

We normally add a match for “illegal” characters in situations lile 
these, for example:

	{	name = "string.quoted.double.hex.python";
		begin = 'x"';
		end = '"';
		patterns = (
			{	name = "invalid.illegal.not-a-hex-character.python";
				match = "[^\h\n]+";
			}
		);
	}

That way, if you have: `x"abcq123"` then `q` will be highlighted as 
illegal (most themes should give it a red background).


More information about the textmate mailing list