sponsor Vim development Vim logo Vim Book Ad

vim-anyfold : Generic folding mechanism and motion based on indentation

 script karma  Rating 0/0, Downloaded by 1926  Comments, bugs, improvements  Vim wiki

created by
Patrick Seewald
 
script type
indent
 
description
For examples and full documentation, visit the official repository
https://github.com/pseewald/vim-anyfold

This plugin comes with the following features:
* Folding mechanism based on indented blocks that has a very intuitive and predictable behaviour.
* Results comparable to syntax aware folding methods but fast and generic algorithm that does not rely on language specific rules.
* Works out of the box for any filetypes, optimal results for all indented languages (including properly indented curly brace languages).
* Shortcuts to navigate to beginning / end of a block and to previous / next indented block.
* Can handle corner cases with ease (comments, varying indentation widths, line breaks).
* Fast update mechanism that keeps folds in sync with buffer.

It has the following shortcomings:
* Can not correctly fold mismatched indentation and thus should only be used together with disciplined programming style (or in combination with Vim's equalprg autoindent feature).

Setup and Usage:
1. Install this plugin with a vim plugin manager.
2. Add the following lines to your vimrc (if not already present).

    filetype plugin indent on
    syntax on
    let anyfold_activate=1
    set foldlevel=0

Choose a higher foldlevel if you prefer to have folds open by default.
3. Use Vim's fold commands zo, zO, zc, za, ... to fold / unfold folds (read :h fold-commands for more information). Use key combinations [[ and ]] to navigate to the beginning and end of the current open fold. Use ]k and [j to navigate to the end of the previous block and to the beginning of the next block.
 
install details
Install this plugin with your preferred vim plugin manager.
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
vim-anyfold-2.0.zip 2.0 2018-03-21 7.4 Patrick Seewald Better defaults for brace based languages and performance optimizations
vim-anyfold-1.1.0.zip 1.1.0 2016-12-02 7.4 Patrick Seewald * Toggle key has been removed
* Fast and direct auto-update of folds
* Performance improvements
* Better defaults for curly-brace languages
* Various bug fixes
AnyFold-1.0.zip 1.0 2016-09-18 7.3 Patrick Seewald First stable release
ip used for rating: 3.81.13.254

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github