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
2
votes
2 answers

Is there a way of code folding the properties just like functions in Xcode?

I like to work with code folding by using option + command + right or left key bindings. It is appearing to me more readable at first glance, especially for long classes. Let me explain with an example, suppose we have a class: func…
zeytin
  • 5,545
  • 4
  • 14
  • 38
2
votes
1 answer

Can't make code folding in dart (flutter) with vs code for specific blocks

I'm trying to make a code folding for the "for loop" and for "if statement " in flutter with vs code but i can't .however the code folding works well if i try to fold the hole class or the body of a method... is that a bug in Dart or i have…
Khalil LAABOUDI
  • 244
  • 1
  • 2
  • 12
2
votes
1 answer

IntelliJ IDEA change preview length of collapsed code

Is there a way to increase the length of the preview/greyed-out code, whenever a block is being folded? So instead of seeing:ChangePas...ostRequest: <2 keys> I'd like to see:ChangePasswordPostRequest: <2 keys>
Edito
  • 3,030
  • 13
  • 35
  • 67
2
votes
4 answers

Indenting code within .R script without using a function

I am new to R, and despite searching the forums I have been unable to find a solution to indenting code within both the Source window and Document Outline (Ctrl+Shift+O). An example is shown below. Ideally, I would want the code to function as…
Patrick
  • 915
  • 2
  • 9
  • 26
2
votes
1 answer

Visual Studio C# 2008: Code Folding Problem when Typing

I have the following problem with code folding: if I have a class with folded methods, and I insert code in between these methods, the lower code unfolds automatically. E.g.: class A { void Method1() [ folded ] void Method2() [ folded ] …
David Ong
  • 117
  • 1
  • 7
2
votes
0 answers

User defined folding regions in eclipse

Does anyone know of any up to date plugins that will allow for custom folding regions in eclipse and are working on 4.5, Mars. Lots of old posts talk about Coffe Beans however I have been unable to get that working with eclipse Mars.
Mike
  • 45
  • 5
2
votes
0 answers

Code folding on curly braces in PhpStorm (PHP)

I like to fold some parts of php code in PhpStorm IDE with in curly braces( {} ) A sample code: $a='a'; $b='b'; { $repeating_var1='1'; $repeating_var2='2'; } How can I define to PhpStorm to fold those part that is in curly brace? As you know…
Seyfi
  • 1,832
  • 1
  • 20
  • 35
2
votes
1 answer

How to manage long code in a single file aside from code-folding?

On the CodeLite website it has the following statement: ...over 13 thousand lines! Seeing its individual functions is hard. One solution (yes, there are others) is to fold the code. What others do they mean when they say "yes there are…
ADJenks
  • 2,973
  • 27
  • 38
2
votes
3 answers

IntelliJ IDEA Code Folding

I started using IntelliJ IDEA to write Java, and one thing kinda annoys me. When I fold a one-line method, it looks like this: . Is there any way to make it look like this?
2
votes
2 answers

Folding Haskell code in Emacs

I was following this guide to set up code folding for Emacs in Haskell. But it does not seem to work: when I do what says in that guide and I try to fold code with the keybindings then it just does not work, nothing happens. If you use Emacs to…
jhegedus
  • 20,244
  • 16
  • 99
  • 167
2
votes
1 answer

Atom IDE : Vertical code folding lines to improve code readability

I have searched on this for quite some time and am unable to find an answer after which I've turned to you folks. I am working with the Atom IDE and my query is very simple - I would like to have to vertical faint lines which run from beginning of…
Aakash
  • 21,375
  • 7
  • 100
  • 81
2
votes
0 answers

Why is code folding working for one file but not the other?

I'm using visual studio 2013 for a Unity3D project and have two .js files, one the code can fold and the other cannot. The file which has folding enabled was hasn't really been touched, but the other file I was able to fold the code when I first…
Drkr
  • 21
  • 2
2
votes
2 answers

Hiding comments with hs-hide-level in Emacs hide-show mode

When I use hs-hide-level, it only hides code blocks at at the current level, but leaves comment blocks at the same level open. For example, if I take the following un-folded code: top level code { /* Level 2 * Multi-line * Comment …
Spevak
  • 55
  • 5
2
votes
1 answer

Why do folded code blocks unfold "automatically" in PhpStorm

While writing code in PhpStorm the folded code blocks unfold automatically. I don't know why and this is making me real crazy. Somebody please help.
Varun
  • 76
  • 5
2
votes
3 answers

vim slows down when using fold-expr

I'm trying to create a simple, fast folding method for large markdown files. I'm using the fold-expr method in vim. For example, if I wanted to start folds on H1 and H2 markdown entries, my vimscript code is: function! MarkdownLevel() if…
user128063
  • 203
  • 1
  • 6