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
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
0answers
32 views

How to save folds? [duplicate]

I made a few folds in my file, but they were gone after I closed it. I'd like to save them somehow somewhere, and teach vim to automatically load them when I open this file.
6
votes
2answers
243 views

Fold/Unfold on moving vertically

Currently my init.vim (neovim's equivalent to the .vimrc) sets the foldmethod to marker: set foldmethod=marker When I open a file all sections are folded and if the curser is placed in the ...
1
vote
1answer
238 views

fold-expr not working as expected

I have trouble with one specific folding expression, s1. The documentation (:h fold-expr) says: "s1", "s2", .. subtract one, two, .. from the fold level of the previous line However ...
8
votes
2answers
3k views

Hide certain lines completely (not folding)

I would like to be able to hide certain lines in my buffer from showing up at all (and being able to toggle seeing them). I found similar questions, but they don't solve my problem. I don't want to ...
2
votes
1answer
437 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 ...
13
votes
1answer
3k views

Can I save folds?

Today I learned how to fold/unfold in Vim; it's quite handy. Unexpectedly, when I exit a file and reenter it, the folds I created are gone (unfolded). In our company's large project there are ...
6
votes
2answers
218 views

Syntax file: keywords within context

I have a language which uses statement like WHILE ... DO .. END_WHILE I can do the following in the corresponding synthax file syn keyword LangKeys WHILE DO END_WHILE syn region LangBlock start="...
3
votes
1answer
650 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={{{,}}...
2
votes
1answer
109 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 ...
8
votes
2answers
738 views

Is there a way to conceal across lines?

Here is my use case: I have lots of code which because of style enforcement we write newlines after and before each open and close brace (respectively). Example: function func(args) { ...
1
vote
1answer
40 views

Automatic folding based on bol

How might Ι automatically fold all paragraphs where every line begins with %%? Would be good for comments in TeX.
5
votes
2answers
1k views

Change what vim displays when there is a fold

When I create a fold with zfap, vim displays something like: +-- 15 lines: myFunctionPrototype :: Test -> Test -> Bool However, I would like vim not to display this number of lines. I find ...
1
vote
1answer
381 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
688 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 ...
7
votes
2answers
4k 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
5k 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
81 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 ...
16
votes
3answers
6k 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
906 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
505 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
323 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
208 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 ...
9
votes
1answer
623 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 ...
14
votes
1answer
6k 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
172 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
549 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
959 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
489 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 ...
10
votes
3answers
4k 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
608 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 ...
13
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
792 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
189 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
3k 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 ...
12
votes
2answers
3k 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
336 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.