Questions tagged [code-folding]

Code folding is a feature of Emacs that allows one to ‘fold’ (collapse/hide) and ‘unfold’ (expand/reveal) large blocks of code.

Filter by
Sorted by
Tagged with
0 votes
1 answer
10 views

Copy-visible for hideshow mode?

Is there an analog of org-copy-visible for hideshow minor mode? An example use case is: enter Python file -> hide all top-level -> copy visible and now I have a list of top-level defs in the ...
Eric Auld's user avatar
0 votes
0 answers
26 views

Python parenthesis folding in doom emacs

I run into situations a lot where I have code that looks like new_stuff = ( blah.blah ( stuff, stuff, stuff, stuff, ).blah_two( [morestuff, stuffstuffstuff, stuffffff ] ) ...
Elle Najt's user avatar
  • 126
0 votes
0 answers
20 views

Is it possible to do code folding like feature but for reST/sphinx documents in emacs

I am switching from org-mode to writing docs/notes etc. in restructured text. I was wondering if in emacs we can achieve section/subsection level code folding. An outline-mode in a separate buffer ...
Kabira  K's user avatar
0 votes
0 answers
13 views

How can I make occur work only on visible text (e.g. org outline)?

Is there a way to do an M-x occur on only visible text, similar to how you can make isearch skip folded content with setq-local search-invisible nil? That way we could occur on for example headings of ...
unhammer's user avatar
  • 1,147
1 vote
1 answer
74 views

Fold code between parentheses and brackets in python mode + hideshow

I'm working on a plotly dash app where there are a number of nested blocks of code like the following: dbc.Row( [ dbc.Col( [ <some long code> ...
 user25482's user avatar
0 votes
0 answers
109 views

How to not fold everything when opening an org mode file?

The default behavior of emacs is to unfold everything when opening an org mode file, I want to prevent this from happening sense my org mode files have a lot of text to be hidden. Whenever I open an ...
Mikelenjilo's user avatar
0 votes
1 answer
73 views

Use hs-minor-mode where it's not supported

I'd like to use hs-minor-mode is some buffers that are not related code editing, but still includes some structured data which I'd like to fold. For instance, in eshell I run a program with some debug ...
fevgenym's user avatar
  • 101
1 vote
3 answers
157 views

How can I use org mode's folding mode in markdown-mode?

I am using markdown-mode on a git-commit message. At the bottom of a git-commit I append some lines to remind me what to take care. Example: My commit message... # * # 1. `Separate subject from body ...
alper's user avatar
  • 1,340
0 votes
1 answer
71 views

How to disable hideshow minor mode when editing?

I am trying to implement the following behavior: when hideshow minor mode is enabled and user start editing file (or alternatively pressed spacebar or enter key): automatically execute hs-show-all or ...
WorkPerNap's user avatar
0 votes
2 answers
221 views

Activate origami folding for python only with using use-package

I want to activate origami folding mode for python only. I do use use-package for loading and configuring my packages. This is what I tried so far (use-package origami) (use-package python :ensure ...
buhtz's user avatar
  • 719
5 votes
0 answers
89 views

Is there a way to display the number of lines in a fold?

I have tons of nested headings in Org-mode files, usually collapsed, and I'd like to have a quick look at how many lines are under each of collapsed headings (mostly top-level but sometimes not). ...
aaa's user avatar
  • 436
0 votes
1 answer
637 views

How to fold Org-mode files in VS-Code based on chapters, which do not have a closing tag?

Using Visual Studio Code with the Explicit Folding extension, I am trying to configure it so that the text is folded according to chapters, subchapters, ... in Org-mode files. The Org-mode syntax for ...
Pietro's user avatar
  • 109
1 vote
0 answers
69 views

How to copy displayed ellipsis when buffer content is folded?

I have JSON files in which I am folding away some subnodes with the hideshow mode. This works reasonably well. Now I want to create a new file or buffer with the folded content. For example, my ...
halloleo's user avatar
  • 1,341
1 vote
1 answer
119 views

evil/elpy: Auto-fold when opening a file

I am using Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.24, cairo version 1.16.0) of 2021-03-28, modified by Debian with elpy and evil-mode. When I open a py-file I want everything ...
buhtz's user avatar
  • 719
0 votes
0 answers
19 views

How to dive into the code-folding topic [duplicate]

I am sorry for such a broad question but I have no other idea. I am using Emacs with evil-mode and elpy (for Python files). Not all keyboard shortcuts known from vim are working. When I ask the search ...
buhtz's user avatar
  • 719
1 vote
2 answers
220 views

Hide / fold settings above an image

Is there way to "fold" settings, similar to how I can fold drawers? I have these properties associated with an image: #+NAME: fig:figure name #+CAPTION: figure name #+ATTR_ORG: :width 200 #+...
MT.'s user avatar
  • 145
2 votes
0 answers
86 views

Custom folding citations in AUCTeX

By default, only \cite is folded by AUCTeX. If you want other citation commands to be folded as well, you have to add them to LaTeX-fold-macro-spec-list manually. For example, with (push '("[nc]&...
Vitus Schäfftlein's user avatar
1 vote
0 answers
41 views

Automatically TeX-fold paragraph after "}" + SPC

I have defined the following smartparens pair: (sp-pair "\\textit\{" "\}" :trigger "ital " :wrap "C-S-k") Now, when I write &...
Vitus Schäfftlein's user avatar
0 votes
1 answer
104 views

Close only code folds using evil

How do I close all code folds (but not comments) with evil's code folding? For now I'm using evil-close-folds and evil-open-folds, but it closes all folds, including comments. I'm using spacemacs 0....
Luctins's user avatar
  • 120
2 votes
1 answer
743 views

How to fold nested list items in markdown-mode

I would like to be able to fold nested list items in markdown-mode in the same way that it is possible to do in org-mode, so that, for example, the first sub-item in the following list can be easily ...
user32038's user avatar
8 votes
3 answers
2k views

Folding mode with YAML?

When working with YAML (using yaml-mode), is there a way to fold a hierarchical tree in a DWIM manner (i.e., without manually adding the {{{ ... }}} markers of folding-mode manually)? yaml-mode itself ...
AnoE's user avatar
  • 408
0 votes
1 answer
116 views

Fold second-level (all methods) when opening a py-file (with hs-minor-mode)

I use hs-minor-mode currently. When point is on class Foo... a M-x hs-hide-level will fold all methods of that class. This is exactly the state I need for all *.py files when I open them. Is it ...
buhtz's user avatar
  • 719
1 vote
0 answers
194 views

How is folding setup in org-mode?

I'm trying to setup folding for Abaqus/Calculix inp files. The format is basically as follows: keywords are represented as * and it's contents are what follows. This is quite like org-mode. So far I'...
Nidish Narayanaa's user avatar
1 vote
1 answer
254 views

Unable to fold code in Elpy

I am trying to get code folding to work in Elpy. I have turned the folding module on already. However, I still seem to be unable to fold code. When I click on the first line of a while loop, I get the ...
bluefyre91's user avatar
0 votes
1 answer
215 views

outshine mode changes outline-regexp from markdown's

patient StackExchange, I am learning org-mode and liking its header-folding capacities, which seem much easier than outline-minor-mode. Most of my work is done in markdown mode, though, so I am ...
Steve Petersen's user avatar
2 votes
1 answer
745 views

Emacs + visual line numbers + folding + visual fill column mode

Relative line numbers for me it's a little bit painful topic. I'm using evil (spacemacs) and I want to jump between lines by in vim style like 10j, 4k etc. Is it possible to get line numbers behavior ...
HarryFox's user avatar
0 votes
1 answer
92 views

How to move point to an invisible line (to access an org property when heading is folded)?

I wrote some code to reschedule all headings under a subtree, but it was failing to get the scheduled date of heading in invisible lines, even though it could access other properties such as the name ...
miguelmorin's user avatar
  • 1,897
5 votes
0 answers
927 views

Code Folding in ELPY Not Working

I used several IDEs for Python. I like Spyder, but I have have been a pretty obsessive Emacs user for a LONG time. I install ELPY. It works very well for my needs. However, I cannot get code ...
Pablo A Perez-Fernandez's user avatar
1 vote
1 answer
131 views

Fold all regexp matches

I'm working on email templates using web-mode, which – alas – requires inline styling galore… many of my opening tags won't fit on a single line even on a 4K-Display due to the massive amount of ...
Phylax's user avatar
  • 35
1 vote
1 answer
223 views

Add code block line in emacs

In visual studio, there is a very convenient line with + and - to show the code which blocks it belongs to. I was wondering if there was the same function in emacs. ,
yuxuan's user avatar
  • 781
5 votes
1 answer
431 views

Folding custom regular expressions in emacs?

Consider a pattern/regular expression I will call reg which matches multiple times in an emacs buffer. I want emacs to recognize all matches for reg and replace (temporarily, like folding) each ...
student's user avatar
  • 1,047
3 votes
1 answer
622 views

Can I hide the part of long lines that exceeds the visual line?

Is it possible to hide the part of long lines that exceeds the visual line rather than wrapping it into further visual lines?
Toothrot's user avatar
  • 3,254
3 votes
0 answers
107 views

How to align latex tables when using macro folding

I have a latex table which contains some long commands like includegraphics or href which makes the table very nasty to read. To get a better view I fold all macros in the table and want to use ...
student's user avatar
  • 1,047
12 votes
2 answers
2k views

Fold all methods in a Python class with Evil

How can I fold all the methods in a Python class? I use Evil and would prefer a pure Evil solution, if possible. I'm looking for a quick way to take something like this: class LongClassIDidNotWrite(...
Lorem Ipsum's user avatar
  • 4,447
3 votes
0 answers
56 views

deeply nested loops and conditionals

I am refactoring legacy code. Looks like: for (int i = 0; i < something.length; i++) { .... .... lots of code here .... if (a.good != b.bad) { .... .... .... ...
Pratik Deoghare's user avatar
0 votes
1 answer
378 views

Folding headers containing source code blocks in an org file?

I always refer to org mode when I want to document anything, but what I am struggling with right now is how to make folding mechanism work when my headers contain source code blocks under a list ...
doctorate's user avatar
  • 1,809
5 votes
1 answer
267 views

Auctex: Fold all environments of a specific type in a buffer

With auctex I can run TeX-fold-env the environment on which point currently is located. How can I fold all environments foo (\begin{foo}... \end{foo}) in my buffer at once? And how to unfold all ...
student's user avatar
  • 1,047
6 votes
0 answers
139 views

Unfold/expand tree when undoing

When I hit the wrong key in a folded org-mode buffer and I hit undo, the cursor normally jumps to some folded location and it's pretty hard to understand what is going on. Expanding the parents of ...
Ivan Perez's user avatar
0 votes
0 answers
81 views

vimish-fold fold overlay highlight colour

Is there a way to change vimish-fold's fold highlight colour? I tried customize-group but didn't see an option to change it.
Arktik's user avatar
  • 972
0 votes
3 answers
700 views

Verilog mode to navigate from begin to end

I am using verilog mode for Emacs. I am trying to find which begin is paired with which end. Is there any way to do this in Emacs?
Roarer's user avatar
  • 11
8 votes
2 answers
2k views

JSON file folding and step-by-step unfolding

I need to look at larger, quite deeply nested JSON files in Emacs. Similar to the terminal tool json-view I would like to start with the JSON file completely folded and then open each level step-by-...
halloleo's user avatar
  • 1,341
1 vote
1 answer
808 views

How to fold / collapse the first comment block on file load?

Is there a way to fold the first comment of a file on load? While I don't like code folding in general, it can be handy in this one instance when every file has a boiler plate header which isn't ...
ideasman42's user avatar
  • 8,726
1 vote
0 answers
387 views

outline minor mode folding enhancements wanted

This query is two questions both related to latex major mode (not Auctex), outline minor mode, code folding. I eventually solved these questions myself. My "answers are given below the ========== ...
zugzwang's user avatar
  • 319
1 vote
0 answers
49 views

ESS folding for R6 classes

What is the proper way to install, configure and activate folding of R script files? I followed emacswiki.org/emacs/FoldingMode but it doesn't seems to work. I installed folding.el to .emacs/lisp/. ...
jangorecki's user avatar
3 votes
0 answers
260 views

collapse input cell in ein

I am using ein with emacs 25-3. As some of the cells I am writing contain classes definitions, I would like to be able to collapse them to show only the first line. I know output cells can be toggled ...
manandearth's user avatar
  • 2,108
0 votes
1 answer
428 views

Fold code using headlines inside org-mode elisp source code block

To manage my config I use org-mode. To manage packages inside this I use use-package. Problem is that there are packages that require a lot of configuration like ibuffer and org-mode. Now I'm looking ...
Jens Lange's user avatar
0 votes
1 answer
173 views

Please help understanding following elisp code of origami package

In file origami.el of package origami from MELPA is the function origami-fold-node and there is the following piece of code, which I do not understand: (when (-some? (lambda (pair) (...
jue's user avatar
  • 4,556
4 votes
1 answer
1k views

how do you fold/unfold complex ruby code blocks

I found a snippet that let's me fold bad(large) blocks of code (add-hook 'ruby-mode-hook (lambda () (hs-minor-mode))) (eval-after-load "hideshow" '(add-to-list 'hs-special-modes-alist ...
american-ninja-warrior's user avatar
4 votes
1 answer
406 views

Folding code between a literal "begin"/"end" block using Hideshow

A formatted input file (*.alm) often contains a large section of columned data. To fold this and improve navigation, I've tried to implement a hs-special-mode-alist entry from hideshow.el. (setq hs-...
z-nut's user avatar
  • 43
1 vote
0 answers
130 views

How to disable code folding for coq?

When I do isearch on the buffer having coq mode it somehow executes code folding, something like (... *)... I have tried to use (setq company-coq-disabled-features '(code-folding)) for disabling code ...
drets's user avatar
  • 213