🏠 back to Observable

code folding in the editor

When working with a large snippet of code in a cell or even a small one but having too many short lines such as with vegalite spec or defining some css stylesheets, the cells get pretty long, is there any way to have a code folding functionality? I feel its somehow wrong to ask this functionality as we can ideally break code into multiple cells and unpin them, but I do not want to create new named cells for most of these use cases.

Note: I had to turn off auto code formatting so I can handle large json objects in a single line to make the code shorter. Having a shortcut to format the current cell is also very welcome compared to having it default for all cells in all notebooks.


Thanks for the feedback! I submitted this as a feature request.

1 Like

A little late here but you can put the comment // prettier-ignore on the line before the JSON object to prevent it from being reformatted.


For anyone searching and find this, in the new version of the notebook editor (Next), the keyboard short Shift-Alt-f will format either the current cell, or in some cases just the current selection. It also works in markdown cells.

1 Like