VcsMessageRecall : Browse and re-insert previous VCS commit messages.
| script karma
Downloaded by 508
Comments, bugs, improvements
script versions (upload new version)
This plugin automatically persists commit messages from Git, Mercurial,
Subversion (and potentially other version control systems) when Vim is invoked
as the commit message editor. It sets up mappings and commands to iterate
through stored past messages, and recall the contents (without the boilerplate
text at the bottom of each message) for use in the currently edited message.
This way, you automatically collect a history of (committed or aborted) past
messages, and can quickly base your current message on contents recalled from
- svn_commit (vimscript #1451) will look in the current directory for aborted
subversion commit log messages, and then read in the newest one to your
current commit log.
See MessageRecall-message-usage for the available mappings and commands.
The commit messages are stored separately for each repository, no matter from
which subdirectory of the repository you're committing. The location of the
message store is
As repositories typically contain totally different projects, it's unlikely
that you need to recall messages from a different repository, but if you need
to, you can still pass that path to the :MessageRecall command, or even
reconfigure the plugin to use a single, global message store.
You commit a set of changes via "git commit". Vim is invoked on the
.git/COMMIT_EDITMSG file, which so far just shows the boilerplate comments at
the bottom of the file.
You press CTRL-P to recall the previous commit message, because this commit is
related to it, and you want to re-use parts of its description. The previous
commit message is inserted above the boilerplate.
Was it that message? You browse through some more via CTRL-P and CTRL-N, then
start editing. Oh, there also was some useful information in the third last
commit. A 3_CTRL-P opens that message in the preview window (because your
current message is now modified, and therefore won't be replaced).
From there, you yank and paste the sentence into your current commit message.
You could have also incorporated the entire message via :3MessageRecall,
either from the preview window, or directly inside the current message.
Finally, you finish your message. But DUH! you actually forgot to fix
something. You bail out via :cquit!, and Git aborts the commit. Nothing is
lost, though. On the next try, a simple CTRL-P or :MessageRecall will retrieve
your carefully crafted text.
This script is packaged as a vimball. If you have the "gunzip" decompressor
in your PATH, simply edit the *.vmb.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.
To uninstall, use the :RmVimball command.
- Requires Vim 7.0 or higher.
- Requires the ingo-library.vim plugin (vimscript #4433), version 1.012 or
- Requires the EditSimilar plugin (vimscript #2544), version 2.00 or higher.
- Requires the BufferPersist plugin (vimscript #4115).
- Requires the MessageRecall plugin (vimscript #4116).
You can override the autocmds after the plugin has been sourced, e.g. in a
For example, to use a single, global message store for all Subversion commits:
autocmd! VcsMessageRecall FileType svn,svn.*
\ call VcsMessageRecall#Setup(
\ $HOME . '/.svn-commit-msgs',
\ '--This line, and those below, will be ignored--'
If you use a localized version of the VCS utilities, you have to adapt the
patterns for the boilerplate detection.
Click on the package to download.
ip used for rating: 220.127.116.11
||- Factor out function to and use ingo-library.
- Support Subversion 1.7 repository layout with only a single .svn directory inside the working copy root.
- FIX: Make Mercurial root dir detection work when CWD is outside of the working copy. *** You need to separately install ingo-library (vimscript #4433) version 1.012 (or higher)! ***
- FIX: On Cygwin and Mercurial, the system() calls have a trailing newline, which breaks the concatenation and leads to strange errors.
||- FIX: Typo in function name breaks Subversion support.
- FIX: Avoid determining message store location when a stored message is edited.
- Split off VcsMessageRecall#Setup() to consolidate the setup duplicated for each VCS and to introduce error handling. Exceptions should not reach the user, as this aborts the opening of the file. Rather, just print out the error and continue.
- Revise range regexp again to also match an empty line above the boilerplate; this will be discarded by BufferPersist, anyway. We need a match in that case to properly replace a just-opened, otherwise empty commit message via CTRL-P or :MessageRecall.
||Revise range regexp to avoid capturing an empty line before (more empty lines before) the boilerplate, and to avoid capturing the first line of the boilerplate when at line 1.