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.

26 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
7
votes
0answers
520 views

Highlight line number of folded lines

I want to have uniform highlighting of line numbers (provided by the LineNr and CursorLineNr hl-groups) but the line numbers of folded lines don't obey a particular group (as far as I know), but obey ...
5
votes
1answer
250 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: ...
5
votes
1answer
163 views

How to disable 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 reliably mostly. However, I have one ...
3
votes
1answer
30 views

Record all line-number fold-levels and restore fold-states (despite fold-level change)

I have found myself so extraordinarily frustrated with Vim's foldmethod=syntax behavior that I've contemplated dropping the editor entirely, despite being mostly happy with it for a few years now. ...
3
votes
0answers
107 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
278 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
61 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 ...
2
votes
0answers
37 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 ...
2
votes
0answers
42 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 ...
2
votes
0answers
92 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 ...
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?
2
votes
0answers
489 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
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
1answer
32 views

How to fold nested “if then else end if” statements

I try to write a vim syntax file for folding if-else statements with the syntax: if <condition> then <block to fold> [else <block to fold>] end if Current approach syn region Then ...
1
vote
0answers
32 views

How to make code-folding more efficient

I have a ruby file while is about 5K+ lines long. My current setup uses the vim-ruby plugin. With this, I enable code folding with let ruby_fold = 1 This opens my ruby files pre-folded. I can open ...
1
vote
0answers
77 views

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

Seems to me that fillchars option doesn't include these characters.
1
vote
0answers
262 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
2answers
217 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 ...
1
vote
0answers
42 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?
1
vote
0answers
1k views

autocmd not being executed when opening file

I've added the following lines to my .vimrc after reading about folding the other day (taken from vim.wikia.com): autocmd Syntax html,python,tex setlocal foldmethod=indent autocmd Syntax html,python,...
0
votes
1answer
28 views

change fold sign character

I know per my question remove trailing dashes in foldtext that I can remove the trailing dashes from collapsed fold lines. When a fold is 'open', the sign column has pipe characters '|'. I looked at ...
0
votes
0answers
24 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
0answers
26 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^\...
0
votes
1answer
74 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 ...
0
votes
1answer
99 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
0answers
120 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 ...