Sublime Forum

MySQL highlighting keywords in string - strange behavior

#1

I’m using Sublime v3 build 3065, running on 64 bit Windows 7.

When I have the following code:


$query = "
	INSERT
	INTO	        table
	SET		event	= '". $mysql'eventID'] ."',
			level		= '". $level ."',
			lowerX	= '35',
			upperX	= '45',
			name	= '". $levName$levID] ."'";

Sublime doesn’t do anything to highlight INSERT, INTO or SET. However if I do it like this:


$query = "INSERT
	INTO	        table
	SET		event	= '". $mysql'eventID'] ."',
			level		= '". $level ."',
			lowerX	= '35',
			upperX	= '45',
			name	= '". $levName$levID] ."'";

Then it does highlight INSERT, INTO and SET as MySQL keywords.

Also if I do this:


$query = "INSERT
	INTO	        ". $mysql'tableName'] ."
	SET		event	= '". $mysql'eventID'] ."',
			level		= '". $level ."',
			lowerX	= '35',
			upperX	= '45',
			name	= '". $levName$levID] ."'";

Then Sublime highlights INSERT and INTO but does not highlight SET.

So the first problem seems to be if Sublime sees the quote but the text of the query starts on some other line below that then Sublime doesn’t notice the MySQL keywords.

The second problem is if you close the string and concatenate back to the string, Sublime stops looking for MySQL keywords.

This is not a huge deal for me because I’m coming from a system that doesn’t highlight MySQL keywords at all in a string. But I thought I would point out the behavior. Maybe you know this already. A couple of searches didn’t turn anything up here. If you can make that work, that would be great. If not, I’m sure Earth will continue to spin anyway.

Cheers.

0 Likes