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
1
vote
0 answers

ngx-codemirror - code folding for gherkin mode not working

I have an Angular application and I'm using ngx-codemirror to build a codemirror editor in the application. The editor is in gherkin mode and I need to add support of code folding. In ngx-codemirror there's an option called foldgutter and I have…
Nabarag Paul
  • 319
  • 5
  • 19
1
vote
2 answers

How to automatically collapse code in RShiny app server (reactives, renders, etc)

I am working with a very large RShiny app and want to take advantage of code folding to organize the server.R file in this application. However, when I use the code-fold hotkey, it does not fold the various elements defined in the server (the…
Canovice
  • 9,012
  • 22
  • 93
  • 211
1
vote
1 answer

How can I fix code folding in Visual Studio Code

When opened, Visual Studio Code will show the appropriate vector symbols alongside the line number as usual, but once finished loading the vector symbols that indicate where one should be able to expand or collapse code are gone, and neither…
Caston
  • 144
  • 7
1
vote
1 answer

Python Folding in Neovim

For some reason folding really won't work in neovim for me. I've tried a few different folding plugins and they all just say 'E490: No fold found' when I try to fold a code block. Am I using it correctly? I'm going to the top of a block, eg a for…
Inigo Val
  • 11
  • 2
1
vote
0 answers

How can I activate code folding in spyder 4.0.1 when there is no checkbox in preferences/editor to do so?

I use WSL on my windows laptop and am perfectly fine to use spyder via VcXsrv. Current version: 4.0.1 - if I try to update to a newer version it tells me that 'all requested packages are already installed'. Additionally, I updated anaconda as…
1
vote
1 answer

Is there a way to fold text by indent but start that indent checking at a certain column?

The platform I develop for spits out hundreds of thousands of lines of "stuff". The information it spits out is really quite good, with a timestamp, incidentID, trace level, and calling class on the left then some white space, then the actual log…
Michael Manley
  • 131
  • 1
  • 6
1
vote
1 answer

about auto -code folding blocks of comments in PyCharm

I'm new to PyCharm tool and trying to figure out the rule about auto-generated code-folding blocks of comments in PyCharm (2020.2.1, Community Edition Build PC#202.6948.78). Screenshot of my code: How can I show the code blocker in (A) instead of…
Rich KS
  • 73
  • 6
1
vote
0 answers

Visual Studio wrong code folding in Python

I am writing Python code in Visual Studio 2017, and I have some problems with code folding. Sometimes, (not for all, but consistenly for specific folding points), when I collapse some code it takes also the code below. For example something like…
Quantoor
  • 189
  • 1
  • 1
  • 7
1
vote
1 answer

Collapsing all inner braces in Visual Studio 2019

Suppose we have something like this: { // 1 A(); { // 1.1 B(); { // 1.1.1 { // 1.1.1.1 D(); } X(); { …
1
vote
1 answer

I keep getting "CodeMirror.foldCode is not a function". Does the code folding addon not work with custom/simple modes?

I'm writing a very basic website to help me edit .filter files for Path of Exile. I'm using CodeMirro and have written a custom mode to handle syntax highlighting using the mode/simple.js addon. Now I'm trying to implement code folding based on…
1
vote
1 answer

How to hide empty lines?

I used to work with location list (:lvimgrep) to show contents of the buffer, but recently I have discovered folding as an interesting alternative. I am using foldmethod=expr and foldexpr=getline(v:lnum)=~'.'?1:0 options. All non-empty lines (a.k.a.…
Evgeniy
  • 756
  • 8
  • 17
1
vote
2 answers

How to enable code folding with conditional blocks in PhpStorm (JetBrains)?

I was wondering if there is a way to enable PhpStorm (or any other JetBrains tool that deals with .phtml files) to recognize conditional blocks when collapsing units of code. I have this example:
bem22
  • 276
  • 1
  • 14
1
vote
1 answer

Xcode/Swift Code-Folding

I know I can fold blocks by pressing command + option + left arrow But the problem is when I'm trying to fold a block of lazy codes. Example: private lazy var linePass: UIView = { let line = UIView() line.backgroundColor =…
Mahdi
  • 31
  • 1
  • 5
1
vote
2 answers

How to code fold a SQL select sub query in MSSMS 2012

I have a select query that is big in terms of number of lines . It is made big by a large sub query it needs. I do not want to see the sub query so often now. I want to scroll over it when further developing my main query. I have Intellisense…
Dasal Kalubowila
  • 103
  • 5
  • 22
1
vote
0 answers

Android studio consecutive comments folding

I use code regions in Android Studio this way: When collapsing all my code, Android Studio used to do this: But with the latest update (3.1.1), it now does this: Is there a way to revert to the previous behaviour? EDIT: yes I've been to…
Tim Autin
  • 6,043
  • 5
  • 46
  • 76