Home Download Buy Blog Forum Support

Enable code folding for parentheses

Enable code folding for parentheses

Postby barney on Fri Aug 15, 2014 3:59 pm

I'm primarily a Javascript developer, and I've increasingly embraced function composition as a means of keeping things SOLID, which means a great volume of my code takes the form of arguments passed to functions (often highly nested) – is there a way I can get Sublime Text (3) to recognise parentheses as foldable?

As an example of problem code, here's a common structure I use for defining DOM templates (using Mithril):

Code: Select all
module.exports = {
   controller : function(){
      this.toggleMenu = function(){
         model.menuExpanded( !model.menuExpanded() );
   view       : function( ctrl ){
      return m( 'div', {
         className : 'page' + ( model.menuExpanded() ? ' menuExpanded' : '' )
      }, [
         m( 'button.btn.btn-large', {
            onclick : ctrl.toggleMenu
         }, [
            m( 'span.glyphicon.glyphicon-th-list',
               m( 'span.text-hide', 'Toggle menu display' )
         ] )
      ] );

The majority of the code above is unfoldable as it stands. Is there a RegEx I can modify somewhere to allow multi-line parentheses content to be identified as a collapsible island?
Posts: 1
Joined: Thu Mar 06, 2014 1:03 pm

Return to Technical Support

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot], Yahoo [Bot] and 10 guests