Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

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
26 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 ...
user avatar
0 votes
1 answer
13 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 ...
user avatar
1 vote
0 answers
21 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 ...
user avatar
  • 113
0 votes
1 answer
26 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 ...
user avatar
  • 113
1 vote
1 answer
32 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 ...
user avatar
  • 375
0 votes
0 answers
16 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: ...
user avatar
  • 1
0 votes
1 answer
29 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 ...
user avatar
0 votes
1 answer
23 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 ...
user avatar
3 votes
1 answer
41 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 ...
user avatar
  • 545
1 vote
0 answers
41 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 ...
user avatar
  • 308
3 votes
0 answers
23 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 ...
user avatar
2 votes
1 answer
59 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 ...
user avatar
  • 25
1 vote
1 answer
46 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 ...
user avatar
1 vote
1 answer
67 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 ...
user avatar
0 votes
1 answer
23 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 ...
user avatar
0 votes
1 answer
42 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 ...
user avatar
  • 1,237
0 votes
0 answers
33 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?
user avatar
0 votes
1 answer
92 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 ...
user avatar
1 vote
1 answer
26 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 ...
user avatar
  • 295
0 votes
2 answers
46 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 ...
user avatar
2 votes
0 answers
66 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....
user avatar
  • 145
1 vote
0 answers
44 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 ...
user avatar
  • 111
1 vote
0 answers
28 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 #. ...
user avatar
  • 145
3 votes
1 answer
135 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 ...
user avatar
  • 61
0 votes
1 answer
81 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 ...
user avatar
  • 103
1 vote
2 answers
431 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 &...
user avatar
0 votes
1 answer
101 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 ...
user avatar
0 votes
1 answer
71 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 ...
user avatar
0 votes
1 answer
148 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 ...
user avatar
2 votes
0 answers
183 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 ...
user avatar
  • 123
0 votes
1 answer
26 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 ...
user avatar
  • 432
2 votes
2 answers
83 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 ...
user avatar
0 votes
1 answer
44 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 ...
user avatar
0 votes
1 answer
160 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 ...
user avatar
1 vote
1 answer
48 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&...
user avatar
0 votes
1 answer
36 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 ...
user avatar
  • 820
1 vote
1 answer
43 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: #...
user avatar
  • 33
2 votes
1 answer
107 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 ...
user avatar
0 votes
2 answers
113 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 ...
user avatar
  • 820
1 vote
0 answers
36 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? ...
user avatar
0 votes
1 answer
103 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 ...
user avatar
  • 69
2 votes
1 answer
407 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 ...
user avatar
3 votes
1 answer
80 views

Folding example from Learn Vimscript the Hard Way not working?

I'm reading Learn Vimscript the Hard Way - Chapter 18, which is also about folds. I'm surprised to see that copying the sample code " Vimscript file settings ---------------------- {{{ augroup ...
user avatar
  • 1,572
1 vote
1 answer
223 views

Make fold feature act like Emacs's org-mode fold

In Emacs org-mode, folds use * at the start of the lines, and any * added consecutively, will add a level of indentation to the header. Furthermore, the header text placed after * or any number of it, ...
user avatar
7 votes
1 answer
117 views

How often and when is foldexpr evaluated?

I want to toggle foldmethod between expr and manual because if we always set foldmethod=expr, then the cursor tends to move slowly in vim. I think that foldexpr is evaluated just after switching ...
user avatar
  • 73
3 votes
0 answers
72 views

How does expression folding actually work?

The following is a stripped down version of my folding function for LaTeX documents: setlocal foldmethod=expr setlocal foldexpr=LaTeXFoldsExpr(v:lnum) " Sections to be folded let g:...
user avatar
  • 139
0 votes
1 answer
252 views

Is it possible to fold/unfold only one function

I'm trying to fold my c++ code. Google told me that I should set foldmethod=indent. But this is not what I need. set foldmethod=indent makes all of folds happen automatically when I enter a c++ file. ...
user avatar
  • 873
1 vote
1 answer
112 views

Why does creating a new fold sometimes cause the entire file to be folded?

Sometimes when I create a new fold in vim, it folds the entire file. Why? (foldmethod=manual) e.g., zi (all folds are now open) zi (all folds are now closed) lines 1-309 are folded closed, and lines ...
user avatar
-1 votes
1 answer
685 views

Markdown folding in vim 8.2

I'm using vim 8.2 on Win 10. I want to enable markdown folding with the built-in markdown.vim. But it will not work. I have tried solutions from other questions (e.g., Enable Expr Folding in Markdown ...
user avatar
15 votes
2 answers
4k views

What does three commented curly brackets ("{{{) at the end of a line mean? Is it just a comment?

In the tcomment plugin, specifically in: ~/.vim/pack/tml/start/tcomment.vim/autoload/tcomment.vim and ~/.vim/pack/tml/start/tcomment.vim/plugin/tcomment.vim I'm seeing this at the end of some lines: ...
user avatar

1
2 3 4 5