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
5
votes
1 answer

Is there any way to fold comments when using Swift in Xcode?

With objective-C multi-line comments could be folded. This does not appear to work with swift files. Is there a way to enable it in XCode?
Drew Rosenberg
  • 899
  • 6
  • 7
5
votes
2 answers

Emacs how to show only the lines on or before the cursor in a file

I am a high school computer science teacher and would like to use emacs to present programs to my students. I would like to be able to present the programs, even short ones, one line at a time and not have the whole program show in the emacs buffer…
rainerpm
  • 343
  • 3
  • 7
5
votes
1 answer

How to disable code folding in Qt Creator?

I have a project I'm working on in Qt Creator that requires breakpoints to debug. I would like to be able to add a breakpoint by clicking next to the line number, because it is intuitive to me. However, when I click in Qt Creator, the code is folded…
Wok
  • 4,956
  • 7
  • 42
  • 64
4
votes
1 answer

TextMate: remove trailing spaces and save

I'm using a script to remove trailing spaces and then save the file. The problem is that all my code foldings expand when I use it. How do I change the command so it will keep the code foldings?
Richard
  • 3,839
  • 5
  • 28
  • 34
4
votes
2 answers

Is there a way to hide annotations in Netbeans or Eclipse?

Maybe a dumb question, but it would be nice if there was a way to hide or collapse Java annotations when viewing source in Netbeans (or Eclipse). I'm not finding an option and a quick search didn't turn anything up. Is this one of those "you should…
Boden
  • 4,149
  • 9
  • 43
  • 56
4
votes
0 answers

How to get code folding with shiny embedding in the same rmarkdown html document?

I am trying to create an rmd html document which uses code folding as well as shiny embedding. I have tried to do this using the default shiny rmd doc but adding in code_folding: hide: --- title: "Untitled" author: "Author" date:…
KGee
  • 771
  • 7
  • 26
4
votes
1 answer

IntelliJ: view property values in code

In newer versions of IntelliJ, value of properties used in @Value annotation (and maybe in other contexts) are shown like this: This doesn't work if you have clicked on the preview or because sometimes IntelliJ ignores it: How is it possible to…
Mahozad
  • 18,032
  • 13
  • 118
  • 133
4
votes
2 answers

How to change the folded part color on Vim

I fold some of the functions on my C code. When I fold them, the color becomes gray. Is there any way to change the color of folded part to another color?
alex
  • 1,319
  • 3
  • 16
  • 28
4
votes
1 answer

How to unfold code one level at a time in Sublime Text 2?

Let's say I have a class, some subclasses in it (in Ruby, for example), some methods in them etc.. In ST2 I choose Edit -> Code Folding -> Fold all. When I click the small arrow next to the class name I want to see the class body, but the methods in…
Alexander Popov
  • 23,073
  • 19
  • 91
  • 130
3
votes
2 answers

Emacs feature similar to JEdit's indent folding mode?

Possible Duplicate: Emacs equivalent of Vim's foldmethod = indent JEdit has a mode (specifically, folding mode: indent, in Options) that lets you fold code blocks based purely on indentation. It does not require any additional configuration, or…
Robin Green
  • 32,079
  • 16
  • 104
  • 187
3
votes
0 answers

Code folding of round brackets in RStudio

Is there a way to add code folding arrows next to round brackets in RStudio? For example, in the picture below a can collapse using the little arrow next to it, but no arrow shows up to collapse b. Is it possible to make those round brackets…
JJJ
  • 1,009
  • 6
  • 19
  • 31
3
votes
0 answers

How can you get Xcode to collapse/fold all properties along with methods?

Xcode has the ability to fold methods & functions as part of its multi-folding capability. But one of the things that has always annoyed me is it doesn't also fold properties, either with observers (willSet, didSet) or with computed values (get,…
Mark A. Donohoe
  • 28,442
  • 25
  • 137
  • 286
3
votes
1 answer

How to fold and unfold a if condition, loops, any other code blocks within "{ code }" other than Methods body in XCode 9?

Recently, I have updated my Xcode from version 8 to version 9. but now I face a weird issue and that is code folding ribbon. New version (9) doesn't having such thing in it. After research a lot I find out the way of folding the code but still it…
Ravi Raja Jangid
  • 795
  • 9
  • 16
3
votes
0 answers

R Studio - Code folding includes last blank line?

I'm using R Studio desktop and trying to use code folding. My code looks like this: # first ---- test1 <- 1 # second ---- test2 <- 2 # third ---- test3 <- 3 # fourth ---- test4 <- 4 When it folds, I want it to look like this: # first <> #…
3
votes
1 answer

Code folding for condtional derivatives(#ifdefine) in Qt creator

Is there a way to enable folding-marker for a code block surrounded by "conditional derivative" in Qt-Creator? I checked an old link, where it says it's not possible but it was back in 2012. My Qt Creator version is 3.6.1 and an example code is…
Nakini
  • 772
  • 1
  • 8
  • 19
1 2
3
13 14