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.

0
votes
1answer
17 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
48 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 ...
2
votes
0answers
23 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 ...
0
votes
1answer
29 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
30 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 ...
1
vote
1answer
43 views

Fold: foldtext() for each filetype

how to have foldtext() for each filetype, because each filetype has different kind of fold so multiple foldtext() in vimrc and enable for each filetype. I'm thinking about multiple foldtext() ...
0
votes
2answers
32 views

Is the number of foldtext dashes incorrect?

Ref to :h foldtext() The number of leading dashes depends on the foldlevel. As follow, I think the foldlevel of printf is 1. But, you can see as follow, the number of dashes is 2. I can't ...
2
votes
1answer
42 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.
0
votes
1answer
25 views

folding in matlab

I'm using vim for my matlab editor. And It works nicely, except I cannot get folding to work. I found my syntax file on github: matlab.vim And I wanted to add folding. I changed the line syn ...
0
votes
2answers
53 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 ...
1
vote
1answer
21 views

excluding line numbering from mkview/loadview

I include set number in my .vimrc file to have line numbers automatically displayed upon opening a file. I also use the following code block to automatically save and load the view when closing and ...
2
votes
1answer
36 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
59 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
123 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
23 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
82 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
134 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
49 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
201 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
2answers
78 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
24 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
21 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
46 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 ...
1
vote
1answer
327 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
78 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
2answers
151 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
112 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
2answers
167 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
93 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
80 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
83 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
2answers
359 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
289 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
104 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
199 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
34 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
502 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
69 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
87 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
127 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
62 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
54 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
49 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?
1
vote
1answer
499 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
92 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
222 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
96 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(). ...
5
votes
1answer
261 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
296 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
422 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 ...