Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

2
votes
1answer
24 views

Re-sync _folds_ from start

Vim has a handy feature in :syntax sync fromstart which allows me to fix syntax highlighting when it gets confused during an extended editing session. I map it to <leader>ss (reSync from Start) ...
1
vote
2answers
54 views

separating folds with constant amount of newlines

Is there a succinct way to separate folds, open or closed, by the same number of newlines throughout the buffer? I'm using fold by indent. The goal is two visible blank lines between each fold (...
2
votes
1answer
75 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 ...
0
votes
0answers
22 views

Fold on second line of a region possible?

I have the following snippet of lines output from a test program: [FATAL] No member name supplied Org::Members: 144 Org::Members::...
0
votes
0answers
56 views

Add comment-like support to vim markdown files

My requirement is that I would like to augment the standard markdown behaviour as found in Vim 8.0. I typically edit files whose contents are like the following. Each line of text can vary in length ...
1
vote
0answers
80 views

How to prevent Vim to collapse a fold with foldmethod=indent on a text paste?

I have the foldmethod=indent setting, the problem with it is that when I'm pasting a line or lines before the first line of a fold and all of these lines have the same or a greater level of ...
0
votes
0answers
40 views

formatlistpat — unexpected regex behaviour

Here is a corrected version. The formatlistpat now works. The regex behaves as expected. I leave this question open, because during my tests I came across a warning saying I had too many brackets (I ...
1
vote
1answer
93 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 ...
1
vote
1answer
54 views

Keep current line in same position when toggling folds (zi)?

When toggling folds with zi, any folds expanding above the current line cause the current line to disorientingly jump to a different place on the screen. How can I keep the current line fixed in the ...
1
vote
0answers
17 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 ...
0
votes
1answer
20 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
0answers
39 views

How do I list all (closed) folds?

I want to know which lines are currently visible, excluding lines that are hidden because they are in a closed fold. However, in the docs I couldn't find a function to list all folds for the current ...
0
votes
1answer
99 views

use of foldcolumns in vim

I never thought of the use of foldcolumns in vim. There are - and + signs to indicate foldable or folded parts of the code, that I understand. But what about the numbers inside the cosecutive - signs? ...
1
vote
2answers
52 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 ...
0
votes
1answer
102 views

Fold special comments

I want to fold all special documentation comments, and only all special documentation comments. To do that I created a new syntax, doxygenComment and added highlighting (in red, just to test it). The ...
2
votes
1answer
89 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 ...
0
votes
0answers
48 views

How to view files like this? (Don't display comments or blank lines)

This somehow happened when I clicked back into iTerm. As you can see, the blank lines and comments are not displayed and functioning lines are. Is there a way to do this on purpose? Thanks!
2
votes
2answers
123 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 ...
0
votes
0answers
80 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
40 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 ...
1
vote
1answer
63 views

Vim template/skeleton with folding

I currently have a skeleton file so that whenever I create a new .cpp file, it copies the c++_template.cpp to the new file. I'm using this line in my .vimrc: autocmd BufNewFile *.cpp 0r ~/workspace_c+...
0
votes
0answers
40 views

Can I swap the foldcolumn and signcolumn?

I'd prefer to have the foldcolumn between the signcolumn and the line number column. Is this possible?
0
votes
2answers
288 views

No folding of markdown files

Running neovim 0.1.7. When I open a markdown file, it does not fold - even when I try zM zR zc, etc. :set tells me ft=markdown and foldmethod=syntax How do I get the folding?
5
votes
1answer
207 views

How to make jump to line automatically unfold

When I jump to line (:76) I end up on a fold, but it doesn't open. I can quickly unfold the fold and it gets to the right line, but I want to have the fold unfold automatically to save keystrokes. ...
1
vote
1answer
70 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 ...
7
votes
1answer
174 views

Count number of visible lines in document with folding?

I'd like to write a plugin that automatically sets the foldlevel of a newly opened document so that as much of the document fits on the screen as possible. (In other words, I'd like to make sure short ...
0
votes
0answers
30 views

Autoclose only high-level folds

When foldmethod is set to syntax and foldclose is set, all folds are closed when you enter a buffer. It is possible to close all folds but the several outermost ones with the foldlevel option. I want ...
0
votes
1answer
256 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> ...
3
votes
0answers
63 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
86 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 ...
1
vote
1answer
98 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 ...
0
votes
1answer
50 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 ...
1
vote
1answer
46 views

cnoremap <CR> <CR> breaks search fold opening

In order to switch between relative and absolute line numbering upon entering command-line, I noremap <expr> <CR> to "someStuff". Unfortunately this breaks the foldopen-ing feature for ...
2
votes
0answers
47 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?
0
votes
1answer
338 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?
0
votes
1answer
80 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 {{...
6
votes
1answer
198 views

Highlighting after a line limit

I'd like to highlight sections of a document which are too long (measured in lines) so they will all print on a physical page. Sections are separated with ===. I tried to do it with this code: ...
1
vote
2answers
85 views

Set folding method for c and cpp files, but not h and hpp

I am in the process of customizing my vim setup, and since I write a lot in C, I have a whole function dedicated just for those files, which I call with autocmd filetype c,cpp,h,hpp call C_syntax(). ...
4
votes
1answer
202 views

Brace { } navigation without opening folds

I use {/} a lot for navigating around, but when I do this I never intend to open a fold and jump to blank lines within the fold. How can I nremap { and } to skip over folds?
0
votes
1answer
211 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 ...
3
votes
2answers
332 views

How to start Vimdiff without equal sections folded?

I'd like vimdiff to start with all the folded sections opened. So far I have tried the following: vimdiff -c "set nofoldenable" -R <(tree -d directory1) <(tree -d directory2) with the -c "set ...
0
votes
2answers
249 views

Folding - open all, close one

There are a few commands to use folding (amongst all): za When on a closed fold: open it. [...] When on an open fold: close it [...] zA When on a closed fold: open it recursively. ...
1
vote
0answers
33 views

How to show a list of SCSS rules in vim?

Is there any good outliner for SCSS files in Vim? Or alternatively, is it possible to fold SCSS classes such that the inner classes would be visible as well?
3
votes
1answer
110 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 ...
3
votes
0answers
71 views

no folding while typing

I'm programming mostly in Python/Cython and use foldmethod=syntax (and foldclose=). Overall, this works fairly well, i.e. functions/classes/methods are folded mostly reliably. However, I have one ...
3
votes
0answers
179 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 ...
2
votes
0answers
274 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
1answer
76 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")...
3
votes
1answer
67 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 ...
12
votes
1answer
3k views

How to fold text in a JSON file?

I have a large JSON file. It is not easy to work on all file at a time. I want to fold some content so that I can work on a section of JSON file. E.g.: { obj: {+}, // folded section obj:{ ...