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
2 votes
3 answers
62 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 ...
  • 133
0 votes
0 answers
18 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 ...
  • 101
0 votes
0 answers
16 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 ...
0 votes
2 answers
57 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
  • 123
0 votes
0 answers
23 views

Highlight line number column with manual fold start and end markers

I'm new to folds and just trying to use them. I understand that foldmethod=indent will automatically show folds in the foldcolumn. But I think I generally don't want to use those auto folds but create ...
  • 101
0 votes
1 answer
27 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 ...
1 vote
1 answer
221 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 ...
  • 279
0 votes
1 answer
86 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 ...
0 votes
0 answers
12 views

How do I match the text of v:foldend?

I have modified vim folding to utilize a custom function that will, among other things, make lines consisting of only a single } be folded in with the previous line - so code like this: const foo = () ...
1 vote
0 answers
24 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 ...
  • 309
1 vote
0 answers
18 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 ...
  • 309
1 vote
2 answers
42 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 ...
  • 309
4 votes
1 answer
25 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 :...
  • 309
0 votes
2 answers
24 views

Copy text from all folds, excluding titles

How do I copy all lines from all folds, excluding the fold titles?
  • 309
1 vote
1 answer
15 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 ...
  • 309
0 votes
0 answers
14 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 ...
  • 309
2 votes
0 answers
20 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 ...
  • 61
0 votes
1 answer
65 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?
1 vote
0 answers
297 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 ...
  • 133
0 votes
1 answer
26 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 ...
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 ----------------------------------...
0 votes
1 answer
23 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
0 votes
0 answers
3 views

How to get "foldlevel" number of characters in foldtext? [duplicate]

EDIT Duplicated by vimscript: how to repeat a string N times? ? I currently have the following in my .vimrc: function! MyFoldText() const foldindicator = ">" return v:folddashes . v:...
0 votes
1 answer
25 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 ...
0 votes
1 answer
73 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 ...
  • 21
0 votes
0 answers
21 views

JSON Plugin for path filter?

I often work with massive JSON files. I really would like to find a plugin to filter the buffer to fold on everything except for lines matching a key path. For example: { "something" : [ ...
  • 101
0 votes
0 answers
35 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=...
  • 2,014
3 votes
0 answers
78 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 ...
1 vote
1 answer
163 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 ...
1 vote
0 answers
30 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 ...
  • 113
0 votes
1 answer
78 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 ...
  • 113
2 votes
1 answer
74 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 ...
  • 465
0 votes
0 answers
44 views

Disable nested folds in vim/neovim

I'm using neovim with manual folding. How can I "add" something to an existing fold? Example: I have a todo list where I want to fold away the things that have been completed. 1 My Tasks: ...
  • 1
1 vote
1 answer
75 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 ...
0 votes
1 answer
41 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 ...
3 votes
1 answer
54 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 ...
  • 647
1 vote
0 answers
231 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 ...
  • 368
5 votes
0 answers
34 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 ...
2 votes
1 answer
203 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 ...
  • 25
1 vote
1 answer
59 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 ...
1 vote
1 answer
106 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 ...
0 votes
1 answer
38 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 ...
  • 103
0 votes
1 answer
90 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 ...
  • 1,377
0 votes
1 answer
216 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 ...
1 vote
1 answer
30 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 ...
  • 295
0 votes
2 answers
50 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 ...
2 votes
0 answers
87 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....
  • 207
1 vote
0 answers
67 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 ...
  • 111
1 vote
0 answers
30 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 #. ...
  • 207
4 votes
1 answer
270 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 ...
  • 71

1
2 3 4 5