Questions tagged [code-folding]

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

Code folding is a feature of some text editors that allows one to ‘fold’ and ‘unfold’ large blocks of code. This can be helpful to see a quick overview of a source file:

A C source file with two collapsed (‘folded’) functions, <code>greet</code> and <code>main</code>. The body of the functions are not visible.

However, folds can be expanded to work on a particular part of a file:

The same file as above, but with the definition of <code>main</code> unfolded.

In some editors, folding is indicated by a disclosure triangle in the line number area:

I lied; there are no line numbers. However, in the pane where the line numbers *would* be, there are three triangles: two to collapse the unfolded <code>greet</code> function, and another, in orange, to expand/unfold the folded <code>main</code> function.

Resources

205 questions
235
votes
7 answers

How to collapse all methods in Xcode?

How to collapse all methods in a class in Xcode? Collapsing one by one is not an option anymore.
Omer
  • 5,470
  • 8
  • 39
  • 64
145
votes
14 answers

How to achieve code folding effects in Emacs?

What's the best way to achieve something like code folding, or the type of cycling that org-mode uses. What would be the best solution in elisp to create this type of behavior? EDIT: I'm sorry I was not clear. I want to program something in elisp…
jacob
  • 2,284
  • 3
  • 20
  • 21
126
votes
2 answers

How do I make pyCharm stop hiding (unfold) my Python imports?

Every time I open a Python file PyCharm will hide all imports and shows: import ... within the editor. I have to manually unfold it to see the imports. Where do I find the setting to undo auto-hiding of import statements?
SmCaterpillar
  • 6,683
  • 7
  • 42
  • 70
75
votes
7 answers

Enable code-folding by default

Is there a way to tell XCode fold methods/functions by default when opening a file?
Infinite
  • 2,931
  • 2
  • 27
  • 33
54
votes
3 answers

Code folding in bookdown

The Code folding option in RMarkdown for html documents is awesome. That option makes the programmatic methodology transparent for those who are interested, without forcing the audience to scroll through miles of code. The tight placement of code…
Alex P
  • 1,574
  • 13
  • 28
46
votes
6 answers

Xcode 9 expand/collapse braces/brackets {} side bar missing

Can't find one under Xcode ▶ Preferences/Text Editing ▶ "Code Folding Ribbon" box.
Yakiv Kovalskyi
  • 1,737
  • 1
  • 15
  • 29
44
votes
5 answers

Xcode Swift code folding/collapse

I know we can use "Shift + Alt + Cmd + Left" to fold/collapse swift code in Xcode, but can anyone tell me how to fold/collapse for functions only? Not properties? Or any alternative way? The default folding method does the job, but actually also…
brianLikeApple
  • 4,262
  • 1
  • 27
  • 46
41
votes
9 answers

Does Xcode support regions?

Does Xcode support anything akin to Visual Studio style #region directives for arbitrary code folding?
iano
  • 2,061
  • 1
  • 18
  • 22
39
votes
2 answers

Is it possible to jump to the next closed fold in Vim?

In Vim, I often find myself wanting to do a quick zk or zj to jump to the previous or next fold in a file. The problem is, I frequently want to skip all the open folds, and just jump to the nearest closed fold. Is there a way to do this? I see no…
David
  • 13,133
  • 1
  • 30
  • 39
36
votes
5 answers

Is there any way to fold/collapse regional code in Eclipse?

I used this way to get code folding in Netbeans: // .... // and Visual Studio: #region description ... #endregion but I can't find the same usage in eclipse. How can I use…
PhatHV
  • 8,010
  • 6
  • 31
  • 40
31
votes
4 answers

Enabling Code Folding Bar in Xcode

How to enable the code folding bar next to the line numbers? I googled "code folding Mac"; it's all about triggering code folding and unfolding, but nothing about enabling the bar. I have tried using Editor -> Code Folding -> Fold/Unfold to fold…
Jay Hu
  • 6,041
  • 3
  • 22
  • 33
23
votes
3 answers

Code Folding changes in Xcode 9/10

I know code folding was missing in the early Beta's of Xcode9 and that it is available to fold entire methods with CMD click. But in Xcode 8 i was able to fold code in blocks (i.e. individual if statements) via Editor >> Code Folding >> Fold but in…
joffd
  • 521
  • 5
  • 19
15
votes
1 answer

Python region folding syntax

I know python does not formally support any built in regional code folding syntax. I do know that a few syntaxes exist out in the wild with conventions tied to specific editors and particular comment pairs. I know of the python source code folding…
jxramos
  • 7,356
  • 6
  • 57
  • 105
15
votes
3 answers

IntelliJ IDEA plugin to fold .conf files?

I have a Scala app built with Lift framework. It has a few .conf files. When I open those .conf files in my IntelliJ IDEA Ultimate Fancy Pants Edition, I do not see any buttons to fold those curly braces in those files. Hotkeys do not do it either.…
Vasily802
  • 1,703
  • 2
  • 18
  • 35
13
votes
1 answer

Collapse all inactive preprocessor blocks in Visual Studio

I am working with some third-party code that has a lot of conditional macros. Visual Studio is quite good at detecting the inactive code, i.e. code wrapped in #if...#endif that won't be compiled and I can manually collapse these individually. I…
1
2 3
13 14