Questions tagged [folding]

A feature which lets visually hide (and toggle) regions of a text file, by replacing its contents with a single outline line.

Filter by
Sorted by
Tagged with
0 votes
2 answers
19 views

How to see all the sections when folding Markdown?

I use Neovim without any extra Markdown plugin. With the option let g:markdown_folding = 1 my Markdown document is automatically folded, but only the h1 headers are displayed. I'd like all the headers ...
Florent2's user avatar
  • 133
2 votes
2 answers
45 views

Is it possible to totally hide folded lines?

As title , folded lines usually displays as one line , with the content configurable; is it possible to hide folded lines totally? And of course, I’d hope there’s still a way to unfold them, for ...
athos's user avatar
  • 195
0 votes
1 answer
34 views

Is there a setting for maximum indent level?

After setting manual fold by indent with set foldmethod=indent, I found that seems the max indent level is around 20, i.e. more than 20 levels will collapse together. May I know if there is a setting ...
athos's user avatar
  • 195
0 votes
2 answers
57 views

How to automatically fold html tags?

If I have this react code: <tag> .. </tag> and the cursor is on top of <tag>, tapping on % will make the cursor jump to the closing </tag>. I want to create a vim key mapping ...
abbood's user avatar
  • 733
1 vote
1 answer
122 views

Turn tree-sitter queries into folding

I have the following config in my ftplugin/groovy.lua: vim.opt.foldmethod = "expr" vim.opt.foldexpr = "nvim_treesitter#foldexpr()" I simply want every region that constitutes a ...
Ari Sweedler's user avatar
1 vote
1 answer
45 views

Using a single carret character as the fold character in Neovim using Lua

I am using Neovim v0.9.5 and configured this editor using Lua. I'm searching for a way of using a single caret down (▾) character for folds. Here is what is currently used by Neovim by default. ** ...
Amin NAIRI's user avatar
2 votes
1 answer
61 views

How to set the value of 'foldexpr' to be a lua function?

I have read the documentation on foldexpr, and I have read through Possible to set `foldexpr` using a function reference?. I have tried this: vim.o.foldexpr = function() return "1" end ...
Ari Sweedler's user avatar
0 votes
0 answers
27 views

How to close current fold when foldopen=all?

I have a setup where I want folds to open whenever the cursor moves into a fold, including through vertical motion. I have set foldopen=all. However, I also want to manually close folds as it makes ...
Rob Mosher's user avatar
0 votes
1 answer
31 views

Recursive fold only up to &foldlevel?

I often use zC to close nested folds under the cursor. However this command is not useful in files with a single, global level-zero fold (e.g. fortran program...end program and latex \begin{document}.....
Luke Davis's user avatar
  • 1,397
0 votes
1 answer
49 views

Separating adjacent folds created with foldexpr

So, context: I'd like to use foldexpr to fold by indentation, but including the start and end lines (that are not indented). For example: function TestFunction(args) statements ... end Would ...
Sneez's user avatar
  • 1
1 vote
0 answers
32 views

How to allow manual folds with indent folds defined?

I want to be allowed to create any folds at all, but I also want Vim to generate all the indent-based folds for me so that I can still use indent-based folding. Is there some way to mix indent-based ...
Captain_Obvious's user avatar
1 vote
1 answer
559 views

Setting custom global variables from command-line with `nvim` command

Occasionally I would like to override my standard nvim configuration, for example, to tell it not to load vimtex's folding configuration for a very large or complicated tex file for which I don't need ...
Alex Roberts's user avatar
2 votes
3 answers
118 views

How to fold away C++ system headers in quickfix window?

If I make a mistake in a class in some C++ code, I'll typically get a ton of messages from the compiler about how hard it's tried to find something suitable in system header files. This floods the ...
sh1's user avatar
  • 143
1 vote
0 answers
170 views

Is there a recommended way to recompute folds every time a buffer is changed in Neovim?

According to the documentation, the only command that recompute folds is the zx command. However, the problem is that zx automatically undoes all manually opened or closed folds. If I have a bunch of ...
Anthony's user avatar
  • 111
0 votes
0 answers
47 views

How can I highlight or somehow differentiate between folds and non folded lines?

I have vim folds and love the functionality, but I want to be able to see what text is included in the fold when I open it. Is there anything I can include in my vimrc to have vim specifically color ...
Alexis B.'s user avatar
0 votes
2 answers
180 views

How do I unfold a specific line?

Let's say that I have a file of 100 lines, and all of the lines are folded. How would I unfold only line number 51? foldmethod is manual All lines were folded with 1,$fold
Tony's user avatar
  • 123
1 vote
1 answer
544 views

Which setting prevents folds from automatically folding on save?

in my init.rc I have the following: autocmd BuffWrite *.* mkview autocmd BuffRead *.* silent! loadview In my init.lua I have: vim.opt.foldmethod = 'marker' In my working files I use the following ...
Vinn's user avatar
  • 781
1 vote
1 answer
233 views

Is it possible to use newlines in `xxx` in a fold marker `xxx {{{`?

In my source code, I have this fold marker: // abc {{{ println!("Hello, world!"); //}}} And this is displayed as one line: +-- 3 lines: abc But is it possible to use a newline in abc ...
ynn's user avatar
  • 289
1 vote
1 answer
439 views

No digits in foldcolumn?

I would like my foldcolumn to have foldcolumn=1 width and to show only -, +, and | (happy to have an indication of the existence of a deeply nested fold, I don't need to know what the actual level of ...
Aaron Parisi's user avatar
1 vote
0 answers
52 views

Stop foldmarker inserting hash

I my folds are set with foldmarker={{{,}}}. When I create a fold it inserts a comment # char before the marker. So it inserts #{{{. How do I stop it doing this? I have syntax highlighting (and it ...
markling's user avatar
  • 369
1 vote
0 answers
21 views

foldtext seems to be recalculated across all folds every time you move the cursor line

With manual folding. Using a system call to put a line/char/word/ count for the text within each fold: :set foldtext=system('wc',getline(v:foldstart+1,v:foldend)) the command works (if you ignore for ...
markling's user avatar
  • 369
2 votes
2 answers
176 views

Change level of manual fold?

How do you increase or decrease the level of the current, manual fold? And what is the keyboard shortcut to do it? I cannot see anything in the manual about this. Foldlevel seems to concern not the ...
markling's user avatar
  • 369
5 votes
1 answer
42 views

Preserve manual folds when saving file under different name

I'm using manual folds. I issued the command :mkview before I exited a file just now, and found that, when I reopened it, the folds appear to be preserved as I left them. But when I issue the command :...
markling's user avatar
  • 369
0 votes
2 answers
45 views

Copy text from all folds, excluding titles

How do I copy all lines from all folds, excluding the fold titles?
markling's user avatar
  • 369
1 vote
1 answer
28 views

Count words in range excluding fold titles

Manual folding has just come as a revelation to me while trying to edit a large text file. The folds define helpful meta-titles for sections of the text. I need a precise word count, but it cannot ...
markling's user avatar
  • 369
0 votes
0 answers
46 views

Foldtext not making any difference to text displayed in closed fold

I changed the value of the foldtext option to change the text displayed in a fold, and it made no difference. I have a short file in which I defined a manual fold containing two lines, with the ...
markling's user avatar
  • 369
2 votes
0 answers
25 views

How to test if a particular FileType has syntax for folds predefined?

I wish to automatically set my foldmethod to manual if syntax fold definitions are not defined for a particular Filetype. However, I am unsure how to check if the fold syntax is defined for the ...
Terry's user avatar
  • 61
0 votes
1 answer
188 views

Nvim where do :mkview get saved on M1 Mac?

My views are saving successfully. But I do not know where they get saved. I looked here: ~/.config/nvim/ and here: ~/.local/share/nvim But there is no views folder. Where are views saved on M1 Mac?
Vinn's user avatar
  • 781
1 vote
0 answers
2k views

Efficiently viewing log files

I have a log file, with each line containing log level {NOT_SET/TRACE,DEBUG,INFO,WARNING,ERROR,CRITICAL}. I would like to have the following functionality: Define custom levels and their priority ...
Rizhiy's user avatar
  • 143
0 votes
1 answer
59 views

Unfold lines that matches a search query

How do I fold many lines and then do a search so that only the lines with search hits pop up while all the rest stay folded? This is how text editors of the 1970s worked. Much appreciated if you can ...
David Solan's user avatar
0 votes
0 answers
24 views

Fold including the top line [duplicate]

With foldmethod=indent, I can create folds based on the indentation level, e.g. this - foo - bar - baz - qux would be folded into this: - foo + -- 2 lines folded ----------------------------------...
Dmitry Zotikov's user avatar
0 votes
1 answer
76 views

Different highlighting between foldtext and "the line number on the folded line"?

Can I control the highlighting of the foldtext separately from the color of the line number on a folded line? I want the foldtext to be quite visible while keeping my chosen line number color
Aaron Parisi's user avatar
0 votes
1 answer
70 views

How do I add indent-based folds to new lines?

I have my .vimrc set up with indent-based folding. But when I make additions to a file, the new text is not foldable. I can manually add folds, but I'd rather not. Is there a way to make vim look ...
Aaron Parisi's user avatar
0 votes
1 answer
173 views

How can I open a vim fold so that it is not affected by `foldclose=all`?

In my config file I have set foldclose=all so that folds get automatically closed upon cursor leaving them. However, sometimes, I want a specific fold not to close for a while. Because folds below ...
lobelk's user avatar
  • 21
0 votes
0 answers
89 views

Can I stylize the current closed-fold line? If yes, how?

I like to have the current line highlighted (in terminal vim), but not as a punch in my eye, so what I have is this in my ~/.vimrc: au ColorScheme * \ hi CursorLine ctermbg=NONE ctermfg=NONE cterm=...
Enlico's user avatar
  • 2,194
3 votes
0 answers
122 views

Is there an easy way to combine multiple fold methods?

I like folding a lot. I like code syntax based folding, custom marker based folding, folding multi line comments, folding parentheses, folding braces, and probably other things I am forgetting. To ...
Zinklestoff's user avatar
1 vote
1 answer
874 views

Change the fold marker characters used to delimit folds [duplicate]

So, oftentimes when I create folds, they actually interfere with other parts of my code and begin folding wherever (n)vim finds another group of three }}} A quick example would be: % {{{ Custom ...
Andy3153's user avatar
  • 161
1 vote
0 answers
66 views

Why zc fold all the sections at the first time?

I have just the following two lines in ~/vimrc to set vim's foldmethod to marker. I do not want all sections are collapsed when the document is opened. So I use nofoldenable to open all marked ...
midnite's user avatar
  • 113
0 votes
1 answer
249 views

zf add fold marker comments with preceding spaces

Setting foldmethod=marker, I can highlight a few lines, press zf to fold them. By default vi will add {{{ and }}} at the ends of the beginning and ending lines. I am working on shell scripts with ...
midnite's user avatar
  • 113
2 votes
1 answer
116 views

Is it possible to keep folds saved when I copy from one file to another?

I've recently discovered I can fold blocks of code with Vim by using zf.Then I can open and close them with zo and zc... I've also seen this solution on StackOverflow that has a vimrc configuration ...
raylight's user avatar
  • 535
1 vote
1 answer
128 views

Fold until next HTML tag

If my cursor is somewhere on an HTML tag, I’d like to invoke a custom command that folds until the closing tag if it finds it, else returns “0” or something. Should I make a function in VimScript or ...
Julius Hamilton's user avatar
0 votes
1 answer
87 views

Custom folding for filetype best practice

In order to keep my tex files organized, i decided to add the following line to my .vimrc, so i can create folds for different parts of them easily by adding "%%" and "%;" as ...
Carla only proves trivial prop's user avatar
3 votes
1 answer
82 views

getting the fold state of lines in nested folds

vim provides the methods foldclosed() and foldclosedend() to get the first and last line of a closed fold. The problem is: It does not respect nested folds. For example this file: line 1 line 2 ...
radlan's user avatar
  • 677
1 vote
0 answers
425 views

Why does the syntax foldmethod not work even though syntax highlighting works?

Started editing a JavaScript file, did :set filetype=javascript (correct syntax highlighting kicked in), then set foldmethod=syntax, and naively expected that folding should automatically work, but ...
toraritte's user avatar
  • 400
5 votes
0 answers
41 views

How to factor fold status with scrollbind?

I'd like two scroll bound windows to factor in fold status when scrolling the other window. For example if a fold is closed, the other window would be scrolled by only 1 line rather than the size of ...
Matthew Webb's user avatar
2 votes
1 answer
407 views

Fold just one line

I have a custom foldexpr to fold comments in markdown. Is there a way to make this fold operation work on just one line? Even if it is just 1 line, I like the color change that folding applies so I ...
yh dev's user avatar
  • 25
1 vote
1 answer
73 views

Treat fold markers as paragraph boundaries?

I'm trying set up text inside default fold markers to be treated as a distinct paragraph. To see, in a new buffer: :set foldmethod=marker This is a paragraph 1 {{{ Want text inside this fold treated ...
Matthew Webb's user avatar
1 vote
1 answer
183 views

disable vim unfolding blocks of text when one of its embedded words is matched

While navigating between search pattern matches , if one of the matches happened to be embedded within a block of text , the whole block gets unfolded . Is there a way to substitute this behavior with ...
xquilt's user avatar
  • 81
0 votes
1 answer
112 views

Quickest Way To Fold Using Marks

I've found if do :set number, I can fold between specific lines x and y with xGzfyG or easier for me xggzfygg. That's great but it's a distraction to find the line numbers as is [visual]zf. I use ...
chipfall's user avatar
  • 103
0 votes
1 answer
144 views

foldmethod setting ignored when initializing vim

I have the following in after/ftplugin/vimwiki.vim setlocal foldmethod=expr setlocal foldenable set foldexpr=VimwikiFoldLevelCustom(v:lnum) I know this file is loading because if I put a syntax ...
StevieD's user avatar
  • 1,492

1
2 3 4 5