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

180 questions
214
votes
5 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,140
  • 8
  • 34
  • 59
128
votes
14 answers

How to achieve code folding effects in Emacs?

Whats 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,084
  • 3
  • 19
  • 21
92
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
  • 5,561
  • 3
  • 33
  • 59
58
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,692
  • 2
  • 25
  • 32
47
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,444
  • 11
  • 26
45
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,697
  • 1
  • 12
  • 28
40
votes
8 answers

Does Xcode support regions?

Does Xcode support anything akin to Visual Studio style #region directives for arbitrary code folding?
iano
  • 1,981
  • 1
  • 17
  • 22
35
votes
5 answers

Code folding 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
  • 7,601
  • 5
  • 29
  • 40
33
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
  • 3,803
  • 1
  • 23
  • 44
29
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
  • 3,815
  • 21
  • 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
  • 481
  • 3
  • 18
22
votes
3 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…
Jieyi Hu
  • 5,861
  • 3
  • 18
  • 32
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…
13
votes
6 answers

Code folding in Emacs

Possible Duplicate: How to achieve code folding effects in emacs An excellent feature of Dreamweaver is code folding of any lines of text -- recursively! It's fantastic, I can fold any text or code, regardless of language. I work with existing…
Christopher Done
  • 5,678
  • 4
  • 31
  • 36
12
votes
2 answers

Handling folds in Spyder

I am coming from a VScode background , and for my recent project (on Deep Learning) I am having to manage huge code files in Spyder (Version 3), and I am not seeing any option of code folding? I am not willing to switch to another IDE , as Spyder is…
abunickabhi
  • 497
  • 2
  • 7
  • 22
1
2 3
11 12