Giter VIP home page Giter VIP logo

fastfold's Introduction

FastFold

Automatic folds (that is, folds generated by a fold method different from manual), bog down VIM considerably in insert mode and are often reevaluated prematurely (for example, when inserting an opening fold marker whose closing counterpart has yet to be added to complete the fold.)

See http://vim.wikia.com/wiki/Keep_folds_closed_while_inserting_text for a discussion.

With this plug-in, the folds in the currently edited buffer are updated by an automatic fold method only

  • when saving the buffer, or
  • when closing or opening folds, or
  • when typing zuz in normal mode

and are kept as is otherwise (by keeping the fold method set to manual). Each of these triggers for updating folds can be disabled by adding

  • let g:fastfold_savehook = 0, or
  • let g:fastfold_togglehook = 0 (which is the default), or
  • let g:fastfold_map = 0

to the .vimrc file.

For example, by adding

set foldmethod=syntax

let g:tex_fold_enabled=1
let g:vimsyn_folding='af'
let g:xml_syntax_folding = 1
let g:php_folding = 1
let g:perl_fold = 1

to the .vimrc file and installing this plug-in, the folds in a TeX, Vim, XML, PHP or Perl file are updated by the syntax fold method when saving the buffer or typing zuz in normal mode and are kept as is otherwise.

==

  • If you prefer that folds are only updated manually but not when saving the buffer, then add let g:fastfold_savehook = 0 to your .vimrc.

  • If you prefer that folds are updated whenever you close or open folds by a standard keystroke such as zx,zo or zc, then add let g:fastfold_togglehook = 1 to your .vimrc.

    The exact list of these standard keystrokes is zx,zX,za,zA,zo,zO,zc,zC,zr,zR,zm,zM,zi,zn,zN and it can be customized by changing the global variable g:fastfold_mapsuffixes (that defaults to let g:fastfold_mapsuffixes = ['x','X','a','A','o','O','c','C','r','R','m','M','i','n','N']).

    A suggested setting is to add

    let g:fastfold_togglehook = 1
    let g:fastfold_mapsuffixes = ['x','X']
    

    to your .vimrc file.

  • If you prefer that this plug-in does not add a normal mode mapping that updates folds (that defaults to zuz), then add let g:fastfold_map = 0 to your .vimrc.

    You can remap zuz to your favorite keystroke, say <F5>, by adding nmap <F5> <Plug>(FastFoldUpdate) to your .Vimrc.

    There is also a command FastFoldUpdate that updates all folds and its variant FastFoldUpdate! that updates all folds and echos by which fold method the folds were updated.

==

Note that this plug-in will overwrite your manual folds when saving the currently edited buffer, unless you either

  • explicitly tell this plug-in to refrain from it via g:fastfold_skipfiles, a list of regular expressions against which the current file name is matched, or
  • when entering the buffer the local and global foldmethod were equal to manual and
  • since then the local and global foldmethod have remained equal to manual, or
  • since then the buffer has not been saved (if let g:fastfold_savehook = 1) and no fold has been toggled (if let g:fastfold_savehook = 1) and zuz (if let g:fastfold_map = 1) has not been typed in normal mode.

===

FastFold.vim integrates with version 1.2 and above of the restore_view.vim plug-in that stores and restores the last folds by the :mkview and :loadview if restore_view.vim is loaded AFTER FastFold.vim. (To ensure the correct autocmd execution order.)

A recent fork of it is available at

http://www.github.com/Konfekt/restore_view

==

A CustomFoldText() function that displays the percentage of the number of buffer lines that the folded text takes up and indents folds according to their nesting level is available at

http://www.github.com/Konfekt/FoldText

fastfold's People

Contributors

desabafo avatar konfekt avatar starcraftman avatar wilywampa avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.