Custom Code Folding

When you’re working with big LookML files (and let’s face it, LookML isn’t exactly a concise language) it’s always worth remembering that the Looker IDE supports code folding, which will collapse the LookML according to pairs of brackets ( ), { } and [ ]. You can find these options in the File Actions menu at the top of the editor (or use the keyboard shortcuts).

You can also exploit this feature to add arbitrary groupings/foldings within your code. As long as the pairs of opening and closing brackets match, it doesn’t matter if they’re commented out - the editor will still recognise the pairs and allow you to collapse your code inside them.

If you have long view files this is a great way to keep your code organised and easy to navigate and edit. You can even use this idea within long SQL blocks, and nest multiple levels of paired brackets if your code is really complex.

I like to use brackets which would likely not be syntactically correct if not commented out, e.g. ( ) in LookML, [ ] in SQL, just so that if they happen to be accidentally un-commented somehow, the mistake will be immediately obvious.

I also like to label both the opening and closing brackets:

# dimensions (

and

# ) /dimensions

This way it’s clear which brackets match which when you're deep into a file, without having to scroll up/down.

Previous
Previous

Row-wise MoM Calculations

Next
Next

Clever Calculations