sponsor Vim development Vim logo Vim Book Ad

mkview.vim : implementation of mkview without requiring a view file

 script karma  Rating 1/1, Downloaded by 1692  Comments, bugs, improvements  Vim wiki

created by
Srinath Avadhanula
script type
This module provides functions which emulate the |mkview| function of vim
without requiring the creation of |view-file|s. This is useful when you
have an explorer type window with some arbitrary level of folding which
needs to be remembered. This module is therefore of interest to script
writers and not to the casual vim user.


1. let viewInfo = MkView()
   This returns a formatted string viewInfo (see file for the format) which
   contains the minimal information needed to
   . Restore manually folds. Restore manually opened and closed folds.
     (this is the behavior of |mkview| when 'viewoptions' contains
   . Restore the cursor row and column position.
   The file is allowed to have arbitrarily nested folds.
   If there is prior information about the folds, then the following
   variants described below can be used.

2. let viewInfo  = MkViewNoFolds()
   When it is known that there are no folds in the file, then use this
   function. It will contain just the information needed to restore the
   cursor row and column positions.

3. let viewInfo = MkViewNoNestedFolds()
   When it is known apriori that there are no folds with |foldlevel|
   greater than 1, i.e, there are no nested folds, then use this function
   which takes advantage of the fact to be faster than MkView(). Nested
   folds, if they exist will be silently ignored if this function is used.

4. call LoadView(viewInfo)
   This function restores the fold state of the file as described in
   MkView(). It eliminates the folds already in the file before restoring
   the original fold state so that additional nestedness is not introduced.
install details
drop in your ~/.vim/plugin directory

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
mkview.vim 1.0 2002-02-17 6.0 Srinath Avadhanula Initial upload
ip used for rating:

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