Sublime Forum

[SOLVED] Append to Existing Syntax Definition

#1

Hello,

I’m looking to modify the existing C syntax definition to include an annoying way my code includes #pragma’s.

My code defines a macro for #pragma which is used all over the place before functions which causes the function list (CTRL+R) to display PRAGMA instead of the actual function.

e.g.,

#define PRAGMA(x)   #pragma (x)
...
PRAGMA(X)
void Function()
{
  ...
}

So what I want to do is update the syntax definition with the following:

		<dict>
			<key>comment</key>
			<string>Stupid PRAGMA()'s</string>
			<key>match</key>
			<string>^(PRAGMA).*$</string>
			<key>name</key>
			<string>keyword.control.import.c</string>
		</dict>

or the JSON pattern:

	{ "match": "^(PRAGMA).*$",
	  "name": "keyword.control.import.c",
	  "comment": "Stupid PRAGMA()'s"
	}

Is there anyway I can do that? I see how I can create an entirely new syntax, but all I want to do is append.

0 Likes

#2

Resolved:

I found the language inside my packages and updated it myself…
In Packages\C++\C.tmLanguage:

<string>^\s*((#\s*(pragma\s+mark)\s+(.*))|(PRAGMA)(.*))</string>
0 Likes