Sublime Forum

Global syntax to highlight a specific word

#1

I have a need to highlight ALL occurrences of

???

in every document in Sublime Text.

**Any ideas to get me started?
**
Thanks
Rob

Note:
I read this, but seems to be specific to one language or scope.

docs.sublimetext.info/en/latest/ … definition

{ "name": "Syntax Name",
  "scopeName": "source.syntax_name",
  "fileTypes": ""],
  "patterns": 
  ],
  "uuid": "ca03e751-04ef-4330-9a6b-9b99aae1c418"
}
0 Likes

#2

You can’t apply more than one syntax file to a given file, so you would have to modify every language file you used. As an alternative, you can try PersistentRegexHighlight

0 Likes

#3

Thanks! I’ll try that plugin.
Rob

0 Likes

#4

This worked perfectly so far.

??? is now highlighted in all documents.

Here is my setting file, with regex pattern.
thanks again
Rob

/Users/YourNameLibrary/Application Support/Sublime Text 2/Packages/PersistentRegexHighlight/PersistentRegexHighlight.sublime-settings

{
	// Please see the README for more information on settings.

	// Array of objects containing a regular expression
	// and an optional coloring scheme
	"regex":{
        "pattern": "?]?]?]",
        "color_scope": "color.scope.name",
        "ignore_case": true
    }]

	,

	// If highlighting is enabled
	"enabled": true,

	// If highlighting should occur when a view is loaded
	"on_load": true,

	// If highlighting should occur as modifications happen
	"on_modify": true,

	// File pattern to disable on. Should be specified as Unix style patterns
	// Note, this looks at the absolute path to match the pattern. So if trying
	// ignore a single file (e.g. README.md), you will need to specify "**/README.md"
	"disable_pattern": ],

	// Maximum file size to run the the PersistentRegexHighlight on.
	// Any value less than or equal to zero will be treated as a non limiting value.
	"max_file_size": 0
}
0 Likes

#5

I modified it a bit more, now all occurrences of TODO and ??? will be highlighted in ALL documents.

{
	// Please see the README for more information on settings.

	// Array of objects containing a regular expression
	// and an optional coloring scheme
	"regex":
	{
        "pattern": "?]?]?]",
        "color_scope": "color.scope.name",
        "ignore_case": true
    },
    {
        "pattern": "TODO",
        "color_scope": "color.scope.name",
        "ignore_case": false
    }
    ]
	,
	// If highlighting is enabled
	"enabled": true,

	// If highlighting should occur when a view is loaded
	"on_load": true,

	// If highlighting should occur as modifications happen
	"on_modify": true,

	// File pattern to disable on. Should be specified as Unix style patterns
	// Note, this looks at the absolute path to match the pattern. So if trying
	// ignore a single file (e.g. README.md), you will need to specify "**/README.md"
	"disable_pattern": ],

	// Maximum file size to run the the PersistentRegexHighlight on.
	// Any value less than or equal to zero will be treated as a non limiting value.
	"max_file_size": 0
}
0 Likes

#6

Glad it worked for you. I’d recommend placing your settings in “Packages/User/PersistentRegexHighlight.sublime-settings”. Everything will be merged automatically. This helps keep all your configurations together and from being overridden on accident in the future.

0 Likes

#7

Skuroda:

Hey thanks for followup.

I’m was very aware of the importance of the

/User/

directory, but I was only using it for ST-like settings files. I will definitely do as you suggested.

Rob

0 Likes