Skip to content

Instantly share code, notes, and snippets.

@dennisvennink
Created November 12, 2011 00:46
Show Gist options
  • Save dennisvennink/1359808 to your computer and use it in GitHub Desktop.
Save dennisvennink/1359808 to your computer and use it in GitHub Desktop.
Better JavaScript code folding in TextMate.

For some strange reason, JavaScript code folding in TextMate is limited to functions; leaving out JSON, simple statements delimited by brackets, and arrays.

In order to change this behaviour, open up the Bundle Editor (Bundles → Bundle Editor → Show Bundle Editor). From the dropdown menu in the top left corner select 'Languages', expand 'JavaScript' (click the triangle) and choose the JavaScript Language Grammar (the item with the L next to it). Find 'foldingStartMarker' and 'foldingStopMarker' in the list on the right and replace their values with:

foldingStartMarker = '\{\s*$|\[\s*$|\(\s*$';
foldingStopMarker = '^\s*\}|^\s*\]|^\s*\)';
@dennisvennink
Copy link
Author

This is now the default style of folding in the JavaScript bundle. Update it here: https://github.com/textmate/javascript.tmbundle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment