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.

33 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
7
votes
0answers
560 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
264 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: ...
4
votes
0answers
308 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 ...
3
votes
0answers
121 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
85 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
64 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
55 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
96 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
556 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
0answers
25 views

Only close first fold when file is opened

When I open a file, I want to automatically fold all outer most folds, so no nesting. Here is what I currently have in my config: set fdm=syntax set foldnestmax=20 set foldenable " set foldlevel=99 ...
1
vote
0answers
18 views

XML syntax folding and custom tag spell checking

I have the following in my ~/vim/syntax/xrc.vim to spell check contents of specific tags when editing XRC files that are just XML files with predefined schema: runtime syntax/xml.vim " check ...
1
vote
0answers
18 views

vim - copy folds to a copied file

Any way to copy folds to a copied file? Example: file1 has several folds, now I create a new file cp file2 newfile. newfile doesn't have folds that I had created in vim, of course it won't as cp and ...
1
vote
0answers
28 views

Highlight color columns on top of folds (not below)

I'm highlighting folds and color columns in colors different from the background and from each other. Here's an excerpt of my vimrc with all (potentially) relevant lines: " ~/.vimrc ... " Folding ...
1
vote
0answers
60 views

Folding in VimWiki like in org mode?

I moved from org mode to VimWiki. I used to write "logs" like this * 2020-02-04 FeatureA - progress Feature B - progress The file can get pretty long as you can imagine. Now with ...
1
vote
1answer
40 views

Deleting folds over a range

Working in an index with mucked up manual folds. Would like to delete folds from current line to end of file. Have tried: :.,$zd and :.,$df So far I've just done a visual selection from current ...
1
vote
1answer
153 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
43 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
98 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
306 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
267 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
44 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
0answers
34 views

vimscript: Efficient way to extract portion from line of text

I have a plugin that does syntax highlighting and folding for a kind of data file. The syntax and folding are both dependent on textual values in specific places (columns) of current line of text. ...
0
votes
0answers
20 views

Unable to change foldmethod

I have the following simple line: inoremap <silent> <TAB> <C-o>:set foldmethod=manual<cr> However, after this command is run and I run set foldmethod?, it reports the ...
0
votes
0answers
12 views

How to limit nest-level for folds with vim-anyfold plugin

For folding java code (also nice for c, cpp, python etc.), I just installed the vim-anyfold plugin. In my ~/.vimrc, I've added autocmd Filetype java,c,cpp AnyFoldActivate to automatically activate ...
0
votes
0answers
32 views

“Invalid expression” setting 'foldtext', what is wrong?

I am trying to set 'foldtext', but it seems I misunderstand expressions, types, etc. of Vim fundamentally. Why does the following refuse to work? set foldtext=v:folddashes."TEST" Whereas this works?...
0
votes
1answer
88 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
49 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
113 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
129 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
125 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 ...