Questions tagged [code-folding]

Code folding is a feature of Emacs that allows one to ‘fold’ (collapse/hide) and ‘unfold’ (expand/reveal) large blocks of code.

86 questions
32
votes
2 answers

How can I hide/display LaTeX section just like org-mode does with headlines?

When editing org files, I find it extremely convenient how you can hide and display headlines and their content by just hitting TAB on the headline. For instance, consider the following buffer * Headline 1 Some text here. * Headline 2 Some more…
Malabarba
  • 22,878
  • 6
  • 78
  • 163
31
votes
3 answers

How can I replicate Vim's code folding?

Code folding in Emacs Sometimes I want to fold a block of text. In Vim you have easy folding without fuzz. Without to add any special characters like "markers" or specific regex like {{{. I would like to select a region and fold it, without messing…
ReneFroger
  • 3,855
  • 22
  • 63
20
votes
2 answers

Code-folding extensions for JSON

I am dealing with JSON files with multiple repeated blocks with just one field value (integer) changed - in fact, every changed value is just the previous corresponding value incremented. To make such files easy to read, I would like to be able to…
Pradhan
  • 2,330
  • 14
  • 28
16
votes
2 answers

Outline editing, like org-mode, for JSON

I am trying to edit a Swagger JSON file in emacs. It contains large nested JSON objects, so I want to collapse and hide some of them. I have tried origami-mode, configured as origami-c-style-parser in origami-parser-alist, but it is quite…
Robin Green
  • 949
  • 7
  • 16
16
votes
2 answers

Actionable code folding in Emacs fringe

I would like to configure my Emacs fringe to show code folding sections. For example, BBEdit on the Mac would show the following when editing a JSON file: The marks themselves are actionable: clicking on a mark would expand or collapse the…
Mathieu Legrand
  • 163
  • 1
  • 7
12
votes
2 answers

Fold all methods in a Python class with Evil

How can I fold all the methods in a Python class? I use Evil and would prefer a pure Evil solution, if possible. I'm looking for a quick way to take something like this: class LongClassIDidNotWrite(): def method1(): junk... …
Lorem Ipsum
  • 4,327
  • 2
  • 14
  • 35
8
votes
3 answers

Folding mode with YAML?

When working with YAML (using yaml-mode), is there a way to fold a hierarchical tree in a DWIM manner (i.e., without manually adding the {{{ ... }}} markers of folding-mode manually)? yaml-mode itself seems to have no provisions for that. The…
AnoE
  • 356
  • 1
  • 11
7
votes
2 answers

JSON file folding and step-by-step unfolding

I need to look at larger, quite deeply nested JSON files in Emacs. Similar to the terminal tool json-view I would like to start with the JSON file completely folded and then open each level step-by-step. I've tried Emacs' built-in Hideshow minor…
halloleo
  • 1,215
  • 9
  • 23
7
votes
2 answers

hs-minor-mode with python.el - hide if statements, for/while loops, etc

Currently, I use the hs-minor-mode to collapse my python code and make it easier to work with - however, by default this only folds def my_function(): blocks. Is it possible to get it to work with if, for, while etc. blocks as well? If not, does…
dieggsy
  • 475
  • 2
  • 10
6
votes
0 answers

Unfold/expand tree when undoing

When I hit the wrong key in a folded org-mode buffer and I hit undo, the cursor normally jumps to some folded location and it's pretty hard to understand what is going on. Expanding the parents of the current location after hitting undo does not…
Ivan Perez
  • 400
  • 2
  • 15
6
votes
1 answer

AucTeX: can I hide comments?

Is there a setting in auctex that can hide (fold) comments (paragraphs which start with %)?
MostlyHarmless
  • 1,395
  • 2
  • 13
  • 14
6
votes
0 answers

Making relative line numbers behave well with folds?

Context: I have relative line numbers displayed in emacs. If there is a fold (for example: in org-mode), these relative numbers appear to "jump". For example if I'm on line 0 over a fold, emacs could show me that the next line visible is "50 lines"…
George
  • 879
  • 5
  • 17
6
votes
1 answer

How can I hide general text in parentheses?

I have some legal text that is peppered with digressions and interpolations in parentheses, so many that it is hard to keep track of the main text. Pasting the text into emacs at least allows me to match parentheses easily, but it occurs to me that…
SlowLearner
  • 245
  • 2
  • 6
6
votes
2 answers

Absolute fold level in Emacs?

Is there a way to emulate Vim's folding of .vimrc from Emacs? In other words, I believe most folding and hiding packages in Emacs rely on open and closing expressions. I am not sure of the internals of these, as I have not tried to learn this much…
5
votes
0 answers

Is there a way to display the number of lines in a fold?

I have tons of nested headings in Org-mode files, usually collapsed, and I'd like to have a quick look at how many lines are under each of collapsed headings (mostly top-level but sometimes not). Having absolute line numbers displayed sort of works,…
aaa
  • 426
  • 3
  • 9
1
2 3 4 5 6