New answers tagged

2

You can accomplish this kind of folding fairly easily by using a file expression, using a function to calculate the fold level of the current line. You can start a new fold of level n on a line that starts with n *s (possibly followed by whitespace.) For a line that doesn't start with *, simply use the fold level of the most recent * line above it. That's ...


1

You can use the :normal command to execute a normal command such as zD for all lines in a range. To execute that command in all lines from the current one until the end of the file, you can use: :.,$normal! zD I'm using :normal! to ignore any mappings affecting the zD command and use Vim's native definition of that command. (But if you don't have any such ...


2

Let's look into vim source code: There is a function which is called when a change was made: https://github.com/vim/vim/blob/85629985b71035608a37ba3bde86968481490d46/src/change.c#L429 This function triggers foldUpdate: https://github.com/vim/vim/blob/85629985b71035608a37ba3bde86968481490d46/src/change.c#L537 Which does folding (including foldexpr): https://...


2

If you are ok with set foldmethod=indent and don't need to use other methods (syntax, expr or manual) then add to your vimrc: set foldlevelstart=99 With this option all your folds would be open for a file you edit(open). 'foldlevelstart' 'fdls' number (default: -1) global {not available when compiled without the |+folding| ...


1

This behavior will happen if line 377 is part of a fold that starts at the top of the file, and that fold that is currently open. In that case, the new fold Vim will create will actually start at line 1 (not at line 377) and Vim will close the new fold, effectively folding the whole file. You can reproduce this behavior with: zE (delete all folds.) :1,...


Top 50 recent answers are included