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
4
votes
1answer
129 views

Writing a vim fold expression for fountain.io files

I am curious to see if it would be possible to write a vim fold expression for fountain.io files. Fountain files are plaintext files used by screenwriters. A good start would be to fold along two ...
4
votes
0answers
330 views

Nested syntax folding

Assume I have a syntax as exemplified below and that I want to create a syntax folding definition for the nested begin..end pairs. begin : label a = 0; begin b = 1; end c = 2; begin ...
3
votes
1answer
1k views

Can I use the mouse for folding/unfolding in Gvim?

The title says most of it. For the curious, folding is something I haven't yet included in my workflow. I use gvim most of the time and I often have my hand on the mouse, scrolling through code. Is ...
3
votes
1answer
247 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 ...
3
votes
1answer
91 views

How to search only in a text which is not folded?

I would like to use search in file with folded functions to search only in functions titles. But common vim search searches inside folding and unfolds any hidden text. Is there a way to search only in ...
3
votes
1answer
739 views

Modeline folding not working on help file

I'm writing a helpfile for a plugin, i.e. a foo.txt file that goes in the plugin's doc/ directory. At the bottom of that file I placed the following modeline: vim: tw=70 ft=help fdm=marker fmr={{{,}}...
3
votes
1answer
59 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 ...
3
votes
1answer
87 views

remove trailing dashes in foldtext

When I set foldtext to a simple value like getline(v:foldstart), vim should show the current line, as opposed to the usual + and appropriate number of hyphens - for the foldlevel. However, vim fills ...
3
votes
1answer
117 views

Record all line-number fold-levels and restore fold-states (despite fold-level change)

I have found myself so extraordinarily frustrated with Vim's foldmethod=syntax behavior that I've contemplated dropping the editor entirely, despite being mostly happy with it for a few years now. ...
3
votes
1answer
353 views

Expand all folds created by vim-latex when opening a LaTeX file

I want all my folds to be expanded when I open a LaTeX file. As per web search I added the following at the end of .vimrc set nofoldenable set foldlevelstart=99 set foldlevel=99 But even now its ...
3
votes
1answer
231 views

Vim-Markdown-Folding plugin error BufEnter E117

Inspired by Drew NEIL's course and the 'nested-folding' feature for Markdown files, I've installed the Vim-Markdown-Folding plugin, on my Vim (:version). The GitHub directory was copied into the ~/....
3
votes
0answers
46 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:...
3
votes
0answers
132 views

how to delete a paragraph respecting the folds?

I have a file (filetype=javascript), this is how it looks without folds: and with folds: I can move with the { and } motions skipping the empty lines inside the folds (thanks to these question and ...
3
votes
0answers
208 views

Using folding with plain text? [closed]

Is there a good way to use folding with "plain text" files? But what do I mean by "plain text"? I'm thinking of text like it is used in human communication when no formal structure is required. It ...
2
votes
1answer
4k views

oneliner map to fold all / unfold all

I'm trying to optimize this solution I came up with. The code bellow do works fine. So feel free to use it as a valid solution to this question. nnoremap <F2> :call ToogleFold()<CR> ...
2
votes
2answers
433 views

How to change the fold title in vim

In vim I need to glance over a folded json text and see the value of a key as the folds title? Looking through the help I saw how to fold by reqular expression though not how to change the folds ...
2
votes
1answer
92 views

Only Open Folds With z Commands

If I navigate the first line of a folded function with h,l, etc it will open the fold. Navigating search matches with n will also open a fold if there is a match inside the fold. Can you configure ...
2
votes
1answer
1k views

Recursively open all folds in current open fold?

If I am in an open fold containing closed folds, how do I recursively open all those closed folds? I kind of thought this would be the use-case for zO, but it seems zO only works when the fold is ...
2
votes
1answer
248 views

Folding via foldexpr

I have the following file # # NODE / 11000001 1009.6809 -878.9679 316.3049 NODE / 11000001 1009.6809 -878.9679 316.3049 NODE / 11000001 1009.6809 -...
2
votes
1answer
597 views

Folding my .vimrc doesn't work as expected

To structure my .vimrc a bit better I decided to create a custom fold expression in the file .vim/after/ftplugin/vim/folding.vim which gets loaded automatically for my .vimrc: " The purpose of this ...
2
votes
1answer
72 views

How to unravel wrapped text

One of the files I have has "wrapped" text : Any idea how to unravel it? I am not sure if this is feature of any of my plugins. List of my plugins: Plugin 'VundleVim/Vundle.vim' Plugin 'tpope/vim-...
2
votes
1answer
91 views

How to visual select everything within a pair of fold markers

Are there simple tweaks that I can visual select everything with in a pair of fold markers? Just like what vi" will do for a pair of double quotes. Preferably vi plus some other keys.
2
votes
1answer
133 views

How to unfold a fold the cursor is in using modeline?

I've got automatic folding enabled in my file with the following modeline: " vim:foldmethod=marker:foldlevel=0 I also have an autocmd like this to place the cursor where I left it: if has("autocmd")...
2
votes
1answer
630 views

Benefits of 'set foldmethod=marker', but stop 'zf' from adding markers

If my file already has {{{ fold contents here ... }}} blocks I want them to be automatically folded when I run za; but I want the ability to create a manual fold using zf%, say on just { ...
2
votes
1answer
39 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 ...
2
votes
3answers
386 views

vim-orgmode: unfold everything on file open by default

Currently when I open files in org mode all the top level bullet points are folded. I can see why this is an OK default for a lot of people, but I prefer all text unfolded initially. Is there a ...
2
votes
1answer
3k views

How to prevent folding when Vim is launched? [duplicate]

I added set foldmethod=syntax to my .vimrc, but it automatically folds whenever a new file is opened. Is there a way to prevent auto-folding and just use za to toggle?
2
votes
1answer
187 views

Comment out characters for zf

I use foldmethod=marker in vim with default {{{ and }}} markers and zfcommand to fold/unfold visually selected blocks. It works fine in most file types, for example: /*{{{*/ console.log("this is a ...
2
votes
1answer
372 views

Custom Folding for SQL Files

I've been using Vim for 2 years now but most (basically all) of the advanced functionality I enjoy today is from the great community of plugins available from Vim. As such I have plugins that drive ...
2
votes
1answer
904 views

Create folding with several starting markers

I can create code folding in marker based folding if there is only one starting marker and one ending marker. What if I have to fold a code which has two starting marker and only one ending marker? ...
2
votes
1answer
35 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 ...
2
votes
2answers
84 views

Deleting folds over a range

Working in an index with mucked up manual folds. Would like to delete folds from current line to end of file. Have tried: :.,$zd and :.,$df So far I've just done a visual selection from current ...
2
votes
1answer
246 views

Enable Expr Folding in Markdown

I want to fold in markdown using the built in markdown plugin that I believe should come with the version of vim I have (Vi IMproved 8.1 (2018 May 18, compiled Apr 23 2019 20:02:08)). I am struggling ...
2
votes
1answer
249 views

Make zC close only current and nested folds

How can I make zC fold only the current fold and the ones underneath? now it closes all outer folds. For example, something like this will result in all brackets closing, while I would like to have ...
2
votes
1answer
389 views

Hide fold column whenever `foldenable` becomes false?

In default vim, whenever foldenable is set to false, the left-hand fold column becomes blank but continues to take up valuable screen real estate. It would be better instead if the fold column ...
2
votes
2answers
448 views

folding, curly bracket under the function name

I have these two functions void function_one(){ return; } void function_two() { return; } when I use zM to fold the functions I get +-- 3 lines: void function_one(){-- void ...
2
votes
1answer
116 views

Strange behaviour of scrollbar

When folding is toggled so that 800 line buffer is folded to 80 lines (with the window height being 50 lines), the scrollbar slider dosn't change its length and remains of the same size as when the ...
2
votes
0answers
15 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 ...
2
votes
1answer
35 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'...
2
votes
2answers
345 views

How to fold nested “if then else end if” statements

I try to write a vim syntax file for folding if-else statements with the syntax: if <condition> then <block to fold> [else <block to fold>] end if Current approach syn region Then ...
2
votes
0answers
102 views

custom fold expression to fold functions

I would like to create a custom fold expression for functions of the form x <- function(a,b,c) { ... ... body ... } where the lines starting from function(...) until the closing brace are ...
2
votes
0answers
86 views

Setup to not automatically open/close folds when writing fold-markers (in the presence of a modeline)

Say I have a file: // vim: syntax=rust fdm=syntax { blah blah } Let's say that lines 2 through 4 are folded: // vim: syntax=rust fdm=syntax + { ... } Now I am in insert mode. I insert a newline ...
2
votes
0answers
60 views

Extra fold of docstring when using foldmethod=indent

I am using foldmethod=indent when working on Python files. This is generally ok. However when I unfold a function, I would like the docstring to stay folded even though it is at the same indent level ...
2
votes
0answers
99 views

Manual fold issue on both Mac & Ubuntu

When I set foldmethod=manual and then I'm typing <zc> E490: No fold found is raising. Same story with set foldmethod=marker. The behavior is the same on Mac Sierra and Ubuntu 16.04. I ...
2
votes
0answers
51 views

Syntax highlighting depending on whether whole line is commented

Is it possible to have vim highlight folds differently depending on whether every line in a fold is only comments or whitespace? In that case, how?
2
votes
0answers
606 views

How should I fold a shell script in vim? Is there an existing script or function for this?

I'm working on some shell scripts with a lot of: # Parameter: images.0.created_at if [ -z "$images.0.created_at" ] then echo "images.0.created_at is empty" else woostring="$woostring""...
2
votes
0answers
187 views

What is a good way to structure a long .vimrc? [duplicate]

When you tweak your .vimrc more and more, it is easy to lose the overview about all settings, functions etc. What are some good ways to structure a long .vimrc?
2
votes
0answers
30 views

Folding from occurrence to next; two or more comments

I wanted to fold my LaTeX document and found this: https://tex.stackexchange.com/questions/130586/vim-nice-folding-function (Which seems to indicate that folding has been removed from Latex-Box?) ...
1
vote
2answers
422 views

How to select/delete/yank the contents of only the current fold?

When using foldmethod=marker, how do you select or reference exactly the contents of the current fold? I want to swap the order of two folds. If they were paragraphs, I would do dap { p. However, I ...
1
vote
1answer
320 views

Strange Fold Info Showing in Gutter

It's only happening in one of my .py files when opened with vim, I am getting some kind of fold info in the gutter that shouldn't be there - made up of the characters '2', '-' and '|'. I disabled ...