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
1
vote
1answer
351 views

Vim reseting to foldmethod=manual once navigating buffers

I have created a ftplugin/html.vim file with a custom fold expression. On my .vimrc file I have the following: set foldmethod=syntax "all files use syntax fold method autocmd Syntax html set ...
1
vote
2answers
612 views

Setting foldmethod=expr when re-sourcing vimrc?

I have the following on my vimrc file to handle custom folding: " ++ Folding set foldenable " enable folding ...
6
votes
2answers
3k views

How to open a file with all folds opened?

I've got the following line in my _vimrc file which enables folding for my PHP (and other) files: set foldmethod=indent However, whenever I open a file it starts with every fold closed, but I would ...
1
vote
1answer
54 views

Is it possible for a :map to insert text without fold-closing the inserted text AND leaving the other folds as they are?

I am facing the following problem: a function, triggered by a :nnoremap inserts a few lines into a buffer. Since I have folding enabled with foldexpr=... and the inserted text contains this expression,...
21
votes
8answers
4k views

Is there a best practice to fold a vimrc file

I recently realized that my vimrc is now more than 400 lines long (which IMO is too much I'll try to reduce that) and to make it easier to navigate, read and edit it I decided to investigate the ...
6
votes
1answer
79 views

save unfolded data to separate file

Within vim you can fold away some data that doesn't pertain to what you're looking for at that moment. So I'd like to save that unfolded data to a separate file and look at it closer, but I don't know ...
15
votes
3answers
5k views

How to fold comments?

The syntax foldmethod is great, but sometimes I just want to fold the comments in a source file. Also syntax folding of comments only works for C-Style comments like: /* ... */ But not for ...
3
votes
1answer
817 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 ...
2
votes
1answer
469 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 { ...
9
votes
2answers
309 views

Problem: Moving lines vertically closes folds

When I move lines with m (e.g. :m+1) all my folds are closed. I can then open the folding with zv again and the cursor will be at the position I moved to. I use folding with {{{ }}} marks and have set ...
7
votes
2answers
191 views

Is there a way to disable the foldexpr during autocomplete?

I've noticed that vim's fold method affects the efficiency of autocomplete, e.g. C-N is slow, and C-X L is hideously slow in medium sized files with relatively expensive foldexprs. I can't see the ...
6
votes
1answer
502 views

How to map Enter to custom command EXCEPT in quick fix?

I've remapped <cr> (enter) to za so I can quickly open/close folds. However, now when I use the quickfix window and hit enter it no longer jumps to the line with the error (because it's trying ...
13
votes
1answer
5k views

Fold selected lines

How can I fold and unfold lines selected in visual mode? Lets say I have three paragraphs and I want to fold the first or last two into one line: Test ==== Lorem Ipsum es simplemente el texto de ...
2
votes
1answer
140 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 -...
4
votes
1answer
3k views

Vimwiki: can't fold list items

With vimwiki you can fold headers and lists as following: Example for headers and list folding: = My current task = * [ ] Do stuff 1 * [ ] Do substuff 1.1 * [ ] Do substuff 1.2 * [ ] ...
5
votes
1answer
509 views

Fold with markers, but disable nesting?

I want to fold sections in a document. Each new section should define a top-level fold instead of a nested fold. I want to use a single delimiter to define a fold. Consider an example document: >&...
8
votes
1answer
3k views

HTML syntax folding in VIM?

I was wondering which is the best way to use syntax folding for HTML files. Specially if it can recognize javascript code within <script> tags. I typed set foldmethod=syntax but it does not ...
4
votes
2answers
868 views

Can I get vim to fold comments when using foldmethod=indent

When editing Python files at work I have to include 20+ lines of boilerplate legalese at the start of the file. "start of the file" is not that strict: I'm allowed to include the Python docstring, and ...
5
votes
2answers
455 views

How to create syntax folding for pascal

I mostly want it to automatically create folds for between a begin and an end, although if there's anything more advanced that would be welcome too. I've looked in the help for the pascal syntax and ...
9
votes
3answers
3k views

How to write a fold-expr?

I have read the help page about fold-expr (:h fold-expr) but it didn't explain what's the syntax used in the expression. There were there four examples: :set foldexpr=getline(v:lnum)[0]==\"\\t\" :...
5
votes
1answer
548 views

Why I am losing syntax highlighting when folding code within a <script> tag?

I am working with an HTML file and within a <script> tag specifically. I usually fold my code using the marker method. However an annoying behavior sometimes happens with my syntax highlighting ...
11
votes
1answer
1k views

Folding by regex search pattern

I got a plain text file with whitespace separated columns of values. Like this: AU 3030 .... ... .... AU 3031 .... ... .... AU 3032 .... ... .... AU 3033 .... ... .... IT 48100 ... .. ..... IT ...
13
votes
2answers
2k views

Collapse vim folds to a single line, similar to Atom or Sublime Text

I'm a fan of the way that Atom and Sublime Text handle line folding, where the first line of each fold is visible (complete with syntax highlighting), and a marker is appended to the end of the line ...
5
votes
1answer
716 views

Perl folding with perl_fold_blocks

I have the below settings in my .vimrc relating to Perl code folding. When I type za to toggle folding, it works on any sub { } by just folding up the sub. However, if I za a non-sub block (e.g. ...
3
votes
0answers
180 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 ...
9
votes
2answers
2k views

Folding fails: vim can't find any fold

I'm trying to fold some PHP code, and I have included a cut-down version of some of the code I'm trying to fold at the end of the post. I've tried the following vim commands, but only the ex commands ...
8
votes
2answers
2k views

How do you fold functions automatically?

Is there a way to make Vim fold functions based on the syntax of a function declaration? For example having vim turn a function like this: def foobar(foo,bar): if foo > bar: print "foo" ...
10
votes
1answer
313 views

Is there a way to display folded parts as a tree?

Folding is useful to hide away parts of the document. A visual representation of the folding structure as a tree would be useful for understanding the document structure at a glance.