Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Recently, I obsessively tricked out my ST2 CSS syntax highlighting. My understanding of these *.tmLanguage files is based on trial and error--mostly error. I mention this to note my grasp is <em>spotty</em>, at best.</p> <p>I think the file you want to modify is <code>~/Library/Application Support/Sublime Text 2/Packages/Default/Find Results.hidden-tmLanguage</code></p> <p>Long story short, I think you want to set it up like this gist (which has liberal commenting):</p> <p><a href="https://gist.github.com/4333623#file-find-results-hidden-tmlanguage" rel="noreferrer">https://gist.github.com/4333623#file-find-results-hidden-tmlanguage</a></p> <p>A typical Find in files results will look something like this:</p> <pre><code>Searching 11 files for "feedback-assistance-form" (regex) /_projects/___/group_reg.js: 60 }); 61 62: $asstForm = $help.find('#feedback-assistance-form'); 63 64 if (!$asstForm.length) { 65: console.log('WARN: Feedback assistance: #feedback-assistance-form not found'); 66 return; 67 } /_projects/___/group_register_help_tmpl.html: 6 &lt;div id="group-reg-help"&gt; 7 8: &lt;form id="feedback-assistance-form" class="js-popover help-content hide" action="{% url info.views.assistance_request %}" method="post"&gt; 9 10 &lt;legend&gt;Need Assistance?&lt;/legend&gt; 3 matches across 2 files </code></pre> <p>The <code>Find Results.hidden-tmLanguage</code> parses the results into 3 relevant parts:</p> <ul> <li>The line with the filename</li> <li>An excerpted line without a match</li> <li>An excerpted line with a match</li> </ul> <p>The rules for this are in the <code>&lt;patterns&gt;</code> section:</p> <pre><code>&lt;key&gt;patterns&lt;/key&gt; &lt;array&gt; &lt;dict&gt; &lt;key&gt;match&lt;/key&gt; &lt;string&gt;^([^ ].*):$&lt;/string&gt; &lt;key&gt;captures&lt;/key&gt; &lt;dict&gt; &lt;key&gt;1&lt;/key&gt; &lt;dict&gt; &lt;key&gt;name&lt;/key&gt; &lt;string&gt;entity.name.filename.find-in-files&lt;/string&gt; &lt;/dict&gt; &lt;/dict&gt; &lt;/dict&gt; &lt;dict&gt; &lt;key&gt;match&lt;/key&gt; &lt;string&gt;^ +([0-9]+) &lt;/string&gt; &lt;key&gt;captures&lt;/key&gt; &lt;dict&gt; &lt;key&gt;1&lt;/key&gt; &lt;dict&gt; &lt;key&gt;name&lt;/key&gt; &lt;string&gt;constant.numeric.line-number.find-in-files&lt;/string&gt; &lt;/dict&gt; &lt;/dict&gt; &lt;/dict&gt; &lt;dict&gt; &lt;key&gt;match&lt;/key&gt; &lt;string&gt;^ +([0-9]+):&lt;/string&gt; &lt;key&gt;captures&lt;/key&gt; &lt;dict&gt; &lt;key&gt;1&lt;/key&gt; &lt;!-- capture group 1 --&gt; &lt;dict&gt; &lt;key&gt;name&lt;/key&gt; &lt;!-- name it so it can be colored --&gt; &lt;string&gt;constant.numeric.line-number.match.find-in-files&lt;/string&gt; &lt;/dict&gt; &lt;/dict&gt; &lt;/dict&gt; &lt;/array&gt; </code></pre> <p>These just go through the file, line-by-line, and look for a match. If a match is found, one or more <code>&lt;key&gt;name&lt;/key&gt;</code> definitions are applied to the capturing group(s) of the match, if there are any. These <code>name</code> definitions are referenced in the theme definition file (for instance, Monokai) and the color is applied to the characters matched by the named capturing group.</p> <p>The patterns above are just matches with capturing groups. I think a limitation of this is the match (or it's capturing groups) can't be further processed. </p> <p>What's applied in the gist are patterns of the format:</p> <pre><code>&lt;key&gt;patterns&lt;/key&gt; &lt;array&gt; &lt;dict&gt; &lt;key&gt;begin&lt;/key&gt; &lt;!-- add the filetype extensions, here --&gt; &lt;!-- these are XML formatted files: --&gt; &lt;string&gt;^([^ ].*\.(?:xml|tmLanguage|hidden-tmLanguage|tmTheme):)$&lt;/string&gt; &lt;key&gt;beginCaptures&lt;/key&gt; &lt;dict&gt; &lt;key&gt;1&lt;/key&gt; &lt;dict&gt; &lt;key&gt;name&lt;/key&gt; &lt;string&gt;entity.name.filename.find-in-files&lt;/string&gt; &lt;/dict&gt; &lt;/dict&gt; &lt;key&gt;end&lt;/key&gt; &lt;string&gt;^[^ ]&lt;/string&gt; &lt;key&gt;patterns&lt;/key&gt; &lt;array&gt; &lt;dict&gt; &lt;key&gt;include&lt;/key&gt; &lt;string&gt;#line-numbers&lt;/string&gt; &lt;/dict&gt; &lt;dict&gt; &lt;key&gt;include&lt;/key&gt; &lt;!-- which syntax should match up to the filetype extensions listed above: --&gt; &lt;!-- to find out what the "scopeName" is, refer to the corresponding *.tmLanguage file --&gt; &lt;!-- for XML, this is ~/Library/Application Support/Sublime Text 2/Packages/XML/XSL.tmLanguage --&gt; &lt;string&gt;text.xml&lt;/string&gt; &lt;/dict&gt; &lt;/array&gt; &lt;/dict&gt; &lt;!-- ... can have many more --&gt; &lt;/array&gt; </code></pre> <p>The main thing with this type of pattern is it has a <code>&lt;begin&gt;</code> and an <code>&lt;end&gt;</code>, then it has it's own <code>&lt;pattern&gt;</code> section. When the <code>&lt;begin&gt;</code> regex is matched, the contents of <code>&lt;patterns&gt;</code> are applied until (this is where I get really spotty) an unmatched token is encountered, at which point the <code>&lt;end&gt;</code> is tested. I think.</p> <p>In any event, the gist defines several of these begin-end-patterns blocks, one for each XML, HTML, JavaScript and CSS file types and syntaxes. The <code>&lt;being&gt;</code> regex matches the line with the filename and a particular file extension. This is used to create the start of the "context" for a given syntax. The context ends when elements in the subsequent <code>&lt;patterns&gt;</code> block stop matching and the <code>&lt;end&gt;</code> regex matches. I think you will basically just want to flesh this out for whichever syntaxes you want to highlight in find results... </p> <p>Here is a screenshot of the syntax-highlighted find results I am getting using that gist:</p> <p><img src="https://i.stack.imgur.com/9B4TK.png" alt="Blingwear"></p> <p>I should note, a big issue I encountered is when a block-comment starts in an excerpt but the excerpt doesn't include the characters that end the block-comment. The block-comment just continues until the terminating token is encountered somewhere else in the find results. This extends into subsequent searches, as well.</p> <p>Update:</p> <p>I meant to add that you shouldn't need to recompile anything on startup. <em>Although</em>, it's worth mentioning that you have to restart sublime for the changes in <code>Find Results.hidden-tmLanguage</code> to take effect. If you make this a plugin of some sort, seems like changes would primarily consist of adding new languages, which could just be an infrequent plugin-update.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload