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
64 views

Debugging foldexpr function

I have debug=msg,throw in my .vimrc. When trying to debug a foldexpr function, the echom statements I use to print are ignored and are not accessible by :messages. Any way to make them work?
0
votes
2answers
328 views

Vim: Don't close fold when closing file

Is there a way to make vim not close the current fold I'm in when I close a file? For example: I am typing inside a fold, I save and close the file (without presing zc to close the fold), and then ...
0
votes
1answer
27 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
27 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 ...
0
votes
2answers
45 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 ...
0
votes
1answer
32 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 ...
0
votes
1answer
460 views

How do you disable automatic code folding?

I use foldmethod=indentbut I hate how it starts each file pre-folded. To get around this I put au BufWinEnter * normal zi in my vimrc. That had worked fine so far, but now that I started using CoC, My ...
0
votes
1answer
20 views

Pattern not found: lastlevel = -1

I'm getting one or more of these message when I open up a file I fold with a custom foldexpr function: Pattern not found: lastlevel = -1 I'm not sure what's generating except the lastlevel variable ...
0
votes
1answer
56 views

Define a fold that can not be searched, and that isn't affected by other fold commands?

POD is a markup file that is used by Perl. It's a pretty unreasonable documentation format that has nothing to do with perl (accept for being the only known use-case), and it's sometimes found ...
0
votes
2answers
163 views

Vim: Foldtext contain all content, instead of only the first line

Would like to have all content of the folded block, instead of only the first line. My current foldsettings are: set foldmethod=marker set foldmarker={,} Example how my data is structured: { ...
0
votes
1answer
138 views

Vim: Is it possible to modify syntax rule of the Folded group?

Thank Vim's folding, I can hide irrelevant parts of code/document and work on a small spot of the file. More and more I organize the folded first lines as an outline of the whole file, in each level. ...
0
votes
1answer
149 views

Why does vim ignore commentstring when folding (foldmethod=marker)

I am editing a HTML document (filetype=html) in vim. foldmarker is set to {,}, foldmethod to marker and commentstring to <!--%s-->. When I visually select a region and use zf to create a ...
0
votes
1answer
346 views

Fold: highlight folded text only

I expected the folded text highlighted as below picture (ignore red rectangle): Like above picture, I'd like to have something to recognize that red region of a fold and highlight it only, donot have ...
0
votes
1answer
59 views

Folding RSpec content not depth

Trying to fold content so the 'method definition' / 'explanatory' lines are all showing regardless of depth, and the content between them is folded. Folding examples on the wikis and in tutorials all ...
0
votes
1answer
583 views

Folding doesn't work for C/C++

I've been having a ridiculously hard time getting C/C++ code folding to work with set foldmethod=syntax. To debug my issue I've stripped down my vimrc to only this: set foldmethod=syntax syntax on ...
0
votes
1answer
15 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 ...
0
votes
0answers
42 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. ...
0
votes
0answers
24 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 ...
0
votes
0answers
29 views

How to limit nest-level for folds with vim-anyfold plugin

For folding java code (also nice for c, cpp, python etc.), I just installed the vim-anyfold plugin. In my ~/.vimrc, I've added autocmd Filetype java,c,cpp AnyFoldActivate to automatically activate ...
0
votes
0answers
34 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?...
0
votes
0answers
59 views

File is not folding when opened

Trying to figure out why folds aren't happening as soon as I open a file: set foldenable set foldmethod=expr let g:lastnum = 0 function! FoldFile(lnum) echom 'hi'; if getline(a:lnum) =~? '\v^\...
0
votes
1answer
140 views

Fold: Different highlight style for fold of each filetype

Extend of this question of fold: Fold: foldtext() for each filetype We have fold for each filetype now but each fold need different highlight style of color, because highlight is global I tried to ...
0
votes
0answers
131 views

How to fold lines above the current unless it has less indentation than the current

My intention is to facilitate investigation of deeply buried code. For example, an error is thrown with message "ABC Error" and if | is where the cursor is: function handleRequest(req) { let param ...
0
votes
1answer
413 views

Vim highlights closed folds

Vim has this odd behaviour: when I launch it in a terminal emulator under X, it highlights closed folds, but when I launch it in console, closed folds' representation is more sensible: they are just ...
0
votes
1answer
127 views

How can I open all folds but the last one?

I would like to open all folds in a buffer recursively apart from folds which contain just text and no further folds. I know that zO opens all folds in a buffer but as explained this is different ...
0
votes
1answer
160 views

Why is folding partial disabled in .snippets filetypes?

Something I commonly do in files is add a modeline that says use this {{{...}}} pattern to delimit regions to be folded: # vim: foldmethod=marker When vim first opens the file, the text inside the {{...
-1
votes
1answer
142 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 ...

1 2 3
4