Textmate Tips & Tricks

Adding folding to CSS blocks in TextMate

(From http://stefan.sofa-rockers.org/2010/07/14/adding-sections-folding-css-textmate/)

Top tip for folding CSS according to comments such as:

/* start ContentBlock */

/* end ContentBlock */

  1. Added snippet called “sectionfold” to the Textmate CSS bundle:
    • Bundles -> Bundle Editor -> Show Bundle Editor
    • New Snippet, then paste in the following:
    • /* start ${1:section} */
      $0
      /* end $1 */
    • It gets activated by the tab trigger “sec” (or as you like), and set the scope selector to source.css.
  2. Modify the CSS language definition:
    • foldingStartMarker = '/\*\*(?!\*)|\{\s*($|/\*(?!.*?\*/.*\S))|/\* start \w+ \*/';
    • foldingStopMarker = '(?<!\*)\*\*/|^\s*\}|/\* end \w+ \*/';

Leave a Reply