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
1 answer
23 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
18 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
18 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
42 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
15 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
15 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=...
  • 1,736
2 votes
0 answers
53 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 ...
0 votes
1 answer
50 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
24 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
43 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
1 vote
1 answer
36 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 ...
  • 385
0 votes
0 answers
30 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
45 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
29 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
46 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 ...
  • 587
1 vote
0 answers
97 views

Why doesn't 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 ...
  • 318
3 votes
0 answers
25 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
111 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
51 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
81 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
28 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 ...
0 votes
1 answer
57 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,277
0 votes
0 answers
38 views

Is there a command to jump to the next line after the end of a fold?

If my cursor is on a fold, I'd like to jump down to the next line after the fold ends. Is there a quick way to do that, i.e. by specifying "end of fold" as a place to move to in some way?
0 votes
1 answer
137 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
27 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
47 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
78 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....
  • 175
1 vote
0 answers
51 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
29 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 #. ...
  • 175
3 votes
1 answer
188 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 ...
  • 61
0 votes
1 answer
100 views

Apply `:mkview` to all open tabs at exit from Vim

I use Vim from the CLI and use tabs rather than buffers (as I understand the terminology). I may or may not open multiple files using the -p option, but end up with a few tabs open at once. If I ...
  • 103
1 vote
2 answers
718 views

No fold found with python code, mac and debian

I'm trying to get vim to do code folding with my python code and I could really use your help with the last bit here. I have this in my ~/.vimrc: set number "set tabstop=2 "set expandtab &...
0 votes
1 answer
115 views

folding.vim file, for a specific filetype, is being ignored

I want to write a custom fold-method file for .paul files (based on the example at Learn Vimscript the Hard Way). However, it appears that my folding.vim file is being ignored. I'm running VIM version ...
0 votes
1 answer
108 views

Basic question with folding and foldmethod=indent

I am confused about folding. I am trying to use the foldmethod=indent method, and my setup is as follows: Now when I try to close all folders with zC I get this, which is as expected: However when I ...
0 votes
1 answer
196 views

How can I search only actual differences in vimdiff?

Basically I need to search only in areas marked red, not pink (in the default color scheme). All I can find is how to search the unfolded areas. This is not very useful to me. I have long lines which ...
2 votes
0 answers
230 views

Folding lists in vimwiki with custom folding enabled

vimwiki's help docs, and this answer, both explain how setting g:vimwiki_folding='list' in my vimrc enables list folding for vimwiki files. This lets me use vim's native folding methods on vimwiki ...
  • 133
0 votes
1 answer
28 views

Prevent help page folds from being lost

When I open a help page, create a manual fold, set bufhidden=hide and buflisted, then navigate away from that page, the fold is not restored upon returning. $ vim -u NONE :help " create a manual ...
  • 442
2 votes
2 answers
93 views

Syntax region doesn't stop at the correct end marker

I'm trying to set up folding for #pragma region in C/C++, and it kinda works, but I need to edit out #pragma from the cPreProc syntax region, which is definitely not ideal. If I don't edit it out, the ...
0 votes
1 answer
57 views

How to get or operate on the current fold under the cursor?

I have some text that is folded, and I would like to operate on the entire fold (e.g. with y), agnostic of what kind of fold it is and how it is defined. Is there some general function to obtain the ...
0 votes
1 answer
223 views

Automatically load & save folds of files - except for help files

My current solution to automatically load & save views of a file is the following: " automatically saves & loads folds when closing or opening a file set viewoptions-=options augroup ...
1 vote
1 answer
53 views

Fold swagger verb properties

I have to edit regularly swagger JSON files to add a x-amazon-apigateway-integration property, files looks like: { "openapi": "3.0.0", "info": { "version&...
0 votes
1 answer
49 views

How to unfold lines in ex mode?

1,100fo can fold lines from beginning to 100th line in ex mode,i can unfold the lines in normal mode with zo and just click enter to expand it in insert mode,now how can unfold it in ex mode?1,100nofo ...
  • 870
1 vote
1 answer
48 views

sass folding syntax

i have foldmethod=indent on a .sass file. it auto-folds most blocks fine, except for #id selectors, which it folds into the block above it. for example: :root // folds 3 lines below --base-bg: #...
  • 33
2 votes
1 answer
122 views

What is corrupting my folds? And, more importantly, how can I fix it?

From time to time, I'll open up a document in vim and find that my manual folds are completely messed up. It's like vim decides to ignore its usual markers and, instead, start interpreting random bits ...
0 votes
2 answers
151 views

How to unfold lines in insert mode?

zo can open folded lines in normal mode. What if I'm in insert mode? For example: line1 line2 Fold it with :1,2fold in ex mode; now, the cursor is in the beginning of line1. Then press o to switch to ...
  • 870
1 vote
0 answers
37 views

Adding a syntax group to support fold markers with foldmethod=syntax

With foldmethod=syntax, is it possible to create a syntax group that matches my fold markers, so that i can use both language-specific syntax folding and whatever markers might already be in my code? ...
0 votes
1 answer
130 views

Keep open fold open on `o`

I have a file with foldmethod=indent. I have the folds automatically open when I enter them, and close when I leave them. When I sit in Normal mode on the bottom line of a fold and press o, the fold ...
  • 69
2 votes
1 answer
504 views

How to display a list of all folds?

How can I show a list of all folds? e.g., maybe a list something like: 1-3 12-18 13-16 where <start-line>-<end-line> are the starting and ending lines of the fold. Is there a command-line ...

1
2 3 4 5