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

folding code and moving along?

I recently discovered that vim can fold code. It works quite good with zc but when I move down with j then the code unfolds. How how can I prevent it from unfolding when I move with the cursor? Is ...
0
votes
1answer
18 views

Hide foldcolumn when no folds?

Currently I have set foldcolumn=1, but in a buffer with no folds, it's just a waste of space. Is there a convenient event to listen to in order to automatically toggle it between 0 and 1 (or whatever ...
0
votes
1answer
25 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
1answer
18 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
0answers
22 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^\...
1
vote
0answers
38 views

custom fold expression to fold functions

I would like to create a custom fold expression for functions of the form x <- function(a,b,c) { ... ... body ... } where the lines starting from function(...) until the closing brace are ...
0
votes
1answer
46 views

Is it possible to use newlines in a fold marker?

I am trying to set foldmarker={{{,\n\n\n, so that {{{ starts a fold and two consecutive empty lines end a fold. However, vim treats this as equivalent to foldmarker={{{,nnn. Is it possible to use ...
0
votes
1answer
50 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 ...
2
votes
1answer
65 views

Is there a way to edit only part of a file?

Unlike many people who are looking for this, or a similar sort of feature, it's not actually the file size I care about, I just find myself needing to deal with a very specific section of a file - ...
2
votes
1answer
34 views

How to unravel wrapped text

One of the files I have has "wrapped" text : Any idea how to unravel it? I am not sure if this is feature of any of my plugins. List of my plugins: Plugin 'VundleVim/Vundle.vim' Plugin 'tpope/vim-...
0
votes
2answers
54 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: { ...
1
vote
0answers
58 views

Is there a way to customize the characters used in fold column?

Seems to me that fillchars option doesn't include these characters.
0
votes
1answer
46 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
95 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
34 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
84 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
55 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
92 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
41 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
48 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
59 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
120 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
29 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
86 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
63 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
171 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 ...
1
vote
0answers
211 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 ...
1
vote
1answer
510 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
101 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
35 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
28 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 ...
1
vote
1answer
780 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
170 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
194 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
134 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
226 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
109 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
185 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
102 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
480 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?
6
votes
1answer
460 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
177 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
236 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
1answer
1k 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
84 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 ...
2
votes
0answers
90 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
187 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
89 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
61 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
50 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?