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
0 answers
24 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
23 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
29 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
27 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
227 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
107 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
0 votes
0 answers
132 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
  • 101
0 votes
0 answers
41 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
146 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
0 votes
1 answer
368 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
  • 649
1 vote
1 answer
230 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
  • 279
1 vote
1 answer
346 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
45 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
  • 319
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
  • 319
1 vote
2 answers
118 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
  • 319
4 votes
1 answer
36 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
  • 319
0 votes
2 answers
40 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
  • 319
1 vote
1 answer
23 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
  • 319
0 votes
0 answers
34 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
  • 319
2 votes
0 answers
24 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
158 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
  • 649
1 vote
0 answers
1k 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
  • 133
0 votes
1 answer
50 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
62 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
57 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
138 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
68 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,172
3 votes
0 answers
109 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
589 views

Change the fold marker characters used to delimit folds

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
1 vote
0 answers
46 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
193 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
103 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
  • 525
1 vote
1 answer
116 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 H.'s user avatar
  • 239
0 votes
1 answer
66 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
70 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
366 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
37 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
356 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
70 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
160 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 ...
polendina's user avatar
0 votes
1 answer
80 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
134 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,417
1 vote
1 answer
337 views

How do I undo a fold?

I noticed that when I fold some text with zf and then press u for undo it does not undo the fold but undoes the last text editing action. Is there a general-purpose undo command which also would undo ...
Julius H.'s user avatar
  • 239
1 vote
1 answer
34 views

Unmark as foldable

I have recently discovered that it is possible to visually select and mark that selection as foldable through zf. I tend to use zM & zR to toggle the whole foldable text. However, sometimes I want ...
ogirginc's user avatar
  • 325
0 votes
2 answers
56 views

What's missing to fold vimscript consecutive comments with "syntax" foldmethod inside function, if, while, etc?

This syntax region fold consecutive comments: syn region vimFoldComment \ start="^\z(\s*\"\)" \ end="\(\z1\)\@!" \ transparent fold ...
Alberto Doe's user avatar
2 votes
0 answers
104 views

Why does folding not work for all Perl files?

I have 2 perl files opened in vim. A test file test.pl and another perl file Cbonusstat_TEC_bearb.pl. I made a session to save the environment. If I open vim with the session, the two files are loaded....
Andy A.'s user avatar
  • 225
1 vote
0 answers
86 views

What could interfere with setting foldmethod=indent by autocmd FileType python?

So recently I noticed my autocmd FileType python setlocal foldmethod=indent is not working anymore. The version for my vim is 8.2 When I open a python file everything is working fine except the ...
cccplex's user avatar
  • 111
1 vote
0 answers
44 views

Is it possible folding blocks, comments and pod in perl

I have to edit some perl scripts. There I can fold blocks surrounded by "{}" with :set foldmarker={,} :set foldmethod=marker See Perl folding with perl_fold_blocks Comments starts with #. ...
Andy A.'s user avatar
  • 225
4 votes
1 answer
445 views

Show lines, words, and character count in fold text

I just joined community, and have a quest: I would like to show more content in the fold text marker for folded regions in [Neo]VIM (especially for Markdown files). The default fold text shows number ...
NewUser's user avatar
  • 81

1
2 3 4 5