sponsor Vim development Vim logo go to HTTPS page Vim Book Ad

BufferPersist : Save certain buffers somewhere when quitting them.

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

created by
Ingo Karkat
script type
This plugin automatically persists (parts of) certain buffers when Vim is done
editing the buffer, regardless of whether is was saved to a file or discarded.
In this way, this is related to the built-in persistent-undo functionality,
but rather meant for building a history of file contents to allow browsing and
recall, especially for things like commit messages, where Vim is invoked as
the editor from an external tool.

This plugin is used by:
MessageRecall (vimscript #4116): Browse and re-insert previous (commit,
                                 status) messages.

The plugin is completely inactive until you set it up for a particular
buffer through the following function; you'll find the details directly in the
.vim/autoload/BufferPersist.vim implementation file.

BufferPersist#Setup( BufferStoreFuncref, ... )

Let's store the first three lines of each edited text file in the temp
directory, using the text file's filename prefixed with "preview-":
    function! BufferStore( bufNr )
        return $TEMP . '/preview-' . fnamemodify(bufname(a:bufNr), ':t')
    autocmd BufNew,BufRead *.txt call BufferPersist#Setup(
    \   function('BufferStore'),
    \   {'range': '1,3'}
install details
This script is packaged as a vimball. If you have the "gunzip" decompressor
in your PATH, simply edit the *.vba.gz package in Vim; otherwise, decompress
the archive first, e.g. using WinZip. Inside Vim, install by sourcing the
vimball or via the :UseVimball command.
    vim BufferPersist.vba.gz
    :so %
To uninstall, use the :RmVimball command.

- Requires Vim 7.0 or higher.

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
BufferPersist.vba.gz 1.00 2012-06-25 7.0 Ingo Karkat 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.
SourceForge.net Logo