#ST2/3 Search result syntax highlighting
##Introduction and disclaimer
This is gist contains an edited Find Results.hidden-tmLanguage
which adds syntax highlighting to your ST search results.
As far as I know, there is no plugin that does this and for that reason it needs to be done via config.
DISCLAIMER: Use this HACK at your risk and backup the original files you are about to mess with.
##Usage Guide for Sublime Text 2
- Open the
Find Results.hidden-tmLanguage
file, located in your Packages directory. You can reach that view thePreferences > Browse Packages...
menu. Default locations are:
- OSX: ~/Library/Application Support/Sublime Text 2/Packages/Default/
- WIN: ~\AppData\Roaming\Sublime Text 2\Packages
-
Replace with the file contents with the contents of the gist and make any changes you wish
-
Save changes and restart Sublime.
-
??
-
Profit
##Usage Guide for Sublime Text 3
-
Install the PackageResourceViewer extension either via PackageControl or manually from github
-
Open the Command Pallete and run
PackageResourceViewer: Extract Package
. ChooseDefault
from the list populated below -
The package is now extracted in your packages directory. You can reach that view the
Preferences > Browse Packages...
menu. Default locations are:
- OSX: ~/Library/Application Support/Sublime Text 3/Packages/Default/
- WIN: ~\AppData\Roaming\Sublime Text 3\Packages
-
Replace with the file contents with the contents of the gist and make any changes you wish
-
Save changes and restart Sublime.
##Adding more languages
For example, lets say you want to add SASS to the search results highlighting.
Copy one of the existing definitions, e.g LESS or CSS
<dict>
<key>begin</key>
<string>^([^ ].*\.css:)$</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>entity.name.filename.find-in-files</string>
</dict>
</dict>
<key>end</key>
<string>^[^ ]</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#line-numbers</string>
</dict>
<dict>
<key>include</key>
<string>source.css</string>
</dict>
</array>
</dict>
And make the following changes
- Change
<string>^([^ ].*\.css:)$</string>
to<string>^([^ ].*\.less:)$</string>
- Change
<string>source.css</string>
to<string>source.less</string>
- Save changes and restart
IMPORTANT: To find out the correct key (scope name) to use for your language, you need to do a bit more digging.
-
You need need to find the corresponding
.tmLanguage
file for the language you want, by going through your Packages folder- ST3 users can use
PackageResourceViewer: Extract Package
command to browser through packages and open the required.tmLanguage
file
- ST3 users can use
-
Search for scopeName in the file and copy the value of the xml node
π₯