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
13
votes
3 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
  • 558
  • 2
  • 9
  • 31
13
votes
3 answers

IntelliJ - Copy only visible text after code folding?

Is it possible to fold large blocks of code in IntellJ, select a section of code that encloses the folded section, and only copy the text that is visible? For instance, if I have a JSON file like: { "list1" : [ 1, 2, …
aaroncarsonart
  • 1,054
  • 11
  • 27
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,886
  • 4
  • 35
  • 38
13
votes
7 answers

Code folding (#pragma region) in Qt creator

Is there something similar to explicit code regions for folding in Qt Creator: #pragma region Region_1 void Test() {} void Test2() {} void Test3() {} #pragma endregion Region_1 I can see folding for logical code blocks, but do not know how to…
Horst Walter
  • 13,663
  • 32
  • 126
  • 228
12
votes
2 answers

Code folding in Xcode 8

Is anyone having problem with code folding in Xcode 8? Every time I fold GameScene.swift (or any other file), switch to, for example, AppDelegate.swift, and switch back to GameScene.swift (which were folded before), it unfolds.
Luiz
  • 1,275
  • 4
  • 19
  • 35
8
votes
4 answers

Keyboard shortcut for code folding in Xcode 9

Code folding doesn't work with key binding Shift + Alt + Cmd + <- left in Xcode 9. Is anyone having same problem with Xcode 9?
Sukhpreet
  • 933
  • 1
  • 9
  • 24
7
votes
2 answers

vscode code folding not showing closing brace

How do I make vscode editor show the closing braces of a folded code snippet The image above represents what I have in my editor. However, I want to be able to see the closing braces. Thanks in advance
Ronald M. Kasendwa
  • 410
  • 1
  • 4
  • 11
7
votes
2 answers

Force Xcode to provide code folding?

I'm testing on OS X. I've got a source file that's heavy with preprocessor macros and tests. I'm trying to collapse the code so I can determine why a particular symbol is not being defined. According to Apple's Folding and Unfolding Source Code, I…
jww
  • 97,681
  • 90
  • 411
  • 885
6
votes
5 answers

I don't have the option to fold code anymore in vscode in python

Recently I discovered that the little arrow next to lines in vscode, that allows you to fold parts of the code, had disappeared. I then noticed this was the case only in my Python files. I scoped the internet looking for an answer, but nothing…
6
votes
1 answer

How to save code folding after IDE restart?

I've tried to use code regions https://www.jetbrains.com/help/pycharm-edu/code-folding.html#surrounding_with_comments , folded some regions and restarted PyCharm. When IDE has been restarted, all folded code regions were expanded. How to save code…
Arthur
  • 3,253
  • 7
  • 43
  • 75
6
votes
3 answers

Is there a way to collapse only methods and doc blocks on demand in PhpStorm?

I have seen this question but if I apply the Ctrl+Shift+- shortcut it collapses everything including class, method, doc, if/try-catch/foreach etc. Basically every block within curly braces are folded which makes it a p.i.t.a to view code. I want to…
nawfal
  • 70,104
  • 56
  • 326
  • 368
6
votes
5 answers

Aptana Code Folding?

When i try to use code folding in Aptana it doesn't seem to be working i haven't changed any shortcuts and i can`t get it work the default shortcut is Ctrl+Numpad_Divide any suggestions ?
ahmedelgabri
  • 1,228
  • 3
  • 17
  • 30
5
votes
2 answers

Visual Studio Code - How to prevent comment folding

I love folding my code in visual studio code, but I wish I could still see my comment blocks with multiple lines. I use them for my functions and classes. Is there a way to achive this? For example I have this piece of code: /** *…
borsTiHD
  • 253
  • 3
  • 17
5
votes
1 answer

How to collapse Clojure docstrings in Spacemacs

I am using Spacemacs to write a program in Clojure. I would like to be able to collapse docstrings. I've tried selecting the docstring and pressing z a, however, that ends up collapsing the entire function body. Specifically, I would like to be able…
jason
  • 1,247
  • 1
  • 9
  • 25
5
votes
1 answer

How do I enable Android Studio/IDEA closure folding for anomynous class in Java 8?

I really like Android Studio's code folding for anonymous class: new AsyncTask() { @Override protected Void doInBackground(Void... params) { doSomething(); return null; } }.execute(); into (AsyncTask)…
1
2
3
13 14