Son
Son

Reputation: 1863

Hide lines in Sublime Text

I use Sublime Text for reading program logs and sometimes logs can be very verbose !

I wonder if there is a trick/add-on in Sublime Text that can hide some verbose lines (based on regexp for example) ?

Thanks.

Upvotes: 2

Views: 1695

Answers (1)

MattDMo
MattDMo

Reputation: 102852

You can do this if you create a new syntax definition .tmLanguage file for your logs, and include the foldingStartMarker and foldingStopMarker keys. These files are XML-based, and the folding markers are defined by regular expressions, ranging from the straightforward (from SCSS):

<key>foldingStartMarker</key>
<string>\{\s*$</string>
<key>foldingStopMarker</key>
<string>^\s*\}</string>

to the complex (from Python):

<key>foldingStartMarker</key>
<string>^\s*(def|class)\s+([.a-zA-Z0-9_ &lt;]+)\s*(\((.*)\))?\s*:|\{\s*$|\(\s*$|\[\s*$|^\s*"""(?=.)(?!.*""")</string>
<key>foldingStopMarker</key>
<string>^\s*$|^\s*\}|^\s*\]|^\s*\)|^\s*"""\s*$</string>

If you can divine some regexes for your log files, then all the magic and convenience of code folding is yours. Good luck!

Upvotes: 2

Related Questions