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
1answer
24 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 ...
0
votes
0answers
25 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
1answer
46 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
1answer
23 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 ...
0
votes
2answers
38 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
0answers
52 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....
1
vote
0answers
29 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 ...
1
vote
0answers
26 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 #. ...
3
votes
1answer
66 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 ...
0
votes
1answer
45 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 ...
1
vote
2answers
134 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
1answer
68 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
0answers
22 views

How can I perform conditional text folding in Vim

I would like to fold all text in between "mytext" and "end mytext", For example: mytext ... ... end mytext or between an open parenthesis and closing parenthesis ( ... ... ) How ...
0
votes
1answer
27 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
1answer
67 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
0answers
92 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 ...
0
votes
1answer
24 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 ...
2
votes
2answers
68 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
1answer
33 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
1answer
70 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
1answer
33 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
1answer
22 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 ...
1
vote
1answer
34 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: #...
1
vote
1answer
66 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
2answers
66 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 ...
1
vote
0answers
34 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
1answer
62 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 ...
2
votes
1answer
227 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 ...
3
votes
1answer
69 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 ...
1
vote
1answer
152 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, ...
5
votes
1answer
94 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 ...
3
votes
0answers
57 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:...
0
votes
1answer
161 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. ...
1
vote
1answer
72 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 ...
-1
votes
1answer
443 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 ...
15
votes
2answers
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: ...
2
votes
1answer
36 views

How can I fold some lines on opening a buffer?

I want to fold from "Copyright" to "CONNECTION" every time I open a .c or .h file, so I don't have to see it. The license does have newlines in it in my files, so selecting shouldn'...
3
votes
1answer
487 views

TeX/LaTeX vim fold markers options

In complex files, especially when writing packages with basic TeX-LaTeX code, the standard definition of foldmarker, namely {{{,}}}, is unfortunate — in effect is quite common to have pieces of code ...
1
vote
1answer
28 views

Better folding on file open -- based on file length?

I like having files be opened folded, specially when they are large. However, when they are small, it can be an overkill (like a markdown file with a single heading). In such cases, I'd like to open ...
1
vote
0answers
27 views

Only close first fold when file is opened

When I open a file, I want to automatically fold all outer most folds, so no nesting. Here is what I currently have in my config: set fdm=syntax set foldnestmax=20 set foldenable " set foldlevel=99 ...
1
vote
1answer
64 views

maintain alignment of text after folding

When a block of text is folded in vim, the first line of folded text is displayed in the foldline at a constant offset from the left edge of the window. Can the offset of that text be instead set to ...
0
votes
0answers
85 views

vimscript: Efficient way to extract portion from line of text

I have a plugin that does syntax highlighting and folding for a kind of data file. The syntax and folding are both dependent on textual values in specific places (columns) of current line of text. ...
2
votes
1answer
102 views

Adding a new line after a fold

At the end of a file I have these lines, line 19 is actually a beginning of a 4 line fold. Now if I want to add a new line after the fold, i.e a new line number 24, I usually type 'A' and enter ...
1
vote
1answer
38 views

Is there any way to prevent modelines getting reapplied when files are saved / written?

For some Markdown documents, I like them to open with some sections initially folded (I use the plugin vim-markdown-folding). I've tried setting a modeline that looks like this: <!-- vi: set ...
0
votes
0answers
27 views

Unable to change foldmethod

I have the following simple line: inoremap <silent> <TAB> <C-o>:set foldmethod=manual<cr> However, after this command is run and I run set foldmethod?, it reports the ...
1
vote
0answers
36 views

XML syntax folding and custom tag spell checking

I have the following in my ~/vim/syntax/xrc.vim to spell check contents of specific tags when editing XRC files that are just XML files with predefined schema: runtime syntax/xml.vim " check ...
1
vote
0answers
41 views

vim - copy folds to a copied file

Any way to copy folds to a copied file? Example: file1 has several folds, now I create a new file cp file2 newfile. newfile doesn't have folds that I had created in vim, of course it won't as cp and ...
1
vote
1answer
504 views

Changing foldmarker per filetype with vim 8.2

On an up-to-date Arch system, I set up marker-based folds in vim and python scripts like so: Extracted from my ~/.vimrc [1] set nocompatible " default filetype plugin indent on set nofoldenable set ...
1
vote
0answers
115 views

Highlight color columns on top of folds (not below)

I'm highlighting folds and color columns in colors different from the background and from each other. Here's an excerpt of my vimrc with all (potentially) relevant lines: " ~/.vimrc ... " Folding ...
0
votes
0answers
38 views

"Invalid expression" setting 'foldtext', what is wrong?

I am trying to set 'foldtext', but it seems I misunderstand expressions, types, etc. of Vim fundamentally. Why does the following refuse to work? set foldtext=v:folddashes."TEST" Whereas this works?...