# code folding in the editor

**URL:** <https://talk.observablehq.com/t/code-folding-in-the-editor/3966>\
**Category:** Feedback\
**Created:** [October 3, 2020, 5:32pm UTC](https://talk.observablehq.com/t/code-folding-in-the-editor/3966 "2020-10-03T17:32:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![a10k](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/a10k/32/2609_2.png) [@a10k](https://talk.observablehq.com/u/a10k)\
**Post date:** [October 3, 2020, 5:32pm UTC](https://talk.observablehq.com/t/code-folding-in-the-editor/3966/1 "2020-10-03T17:32:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Cobus](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/cobus/32/9670_2.png) [@Cobus](https://talk.observablehq.com/u/Cobus)\
**Post date:** [October 5, 2020, 11:30pm UTC](https://talk.observablehq.com/t/code-folding-in-the-editor/3966/2 "2020-10-05T23:30:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![j-f1](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/j-f1/32/368_2.png) [@j-f1](https://talk.observablehq.com/u/j-f1)\
**Post date:** [October 15, 2020, 12:43am UTC](https://talk.observablehq.com/t/code-folding-in-the-editor/3966/3 "2020-10-15T00:43:09Z")

</div>

> [@a10k](#):
>
> 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.

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.

---

<div class="post-metadata">

**Author:** ![wiltsecarpenter](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/wiltsecarpenter/32/4175_2.png) [@wiltsecarpenter](https://talk.observablehq.com/u/wiltsecarpenter)\
**Post date:** [July 20, 2021, 9:18pm UTC](https://talk.observablehq.com/t/code-folding-in-the-editor/3966/4 "2021-07-20T21:18:28Z")

</div>

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.
