A small plugin to add the ability to stash file changes in git. This plugin is inspired by fzf.vim, using fzf for its UI to make stash management simple.
This plugin doesn't aim to do much more than stash, but if you're using vim-fugitive like I am, it's one of the few commands you'll be missing.
- Adds a useful interface for managing your stashes, including popping, dropping, and previewing those stashes with meaningless names
- Adds a command to stash all current changes, with the optional ability to name the stash
- Matches both vim-fugitive and fzf.vim in design so that it will feel familiar to anyone who already uses them
This plugin depends on fzf for it's UI. Other than that, almost any version of vim (or neovim) and git should work with this plugin. You must also have vim-fugitive installed.
Using vim-plug, it's as simple as:
Plug 'aacunningham/vim-fuzzy-stash'
This plugin exposes two commands for you to use or bind as you see fit:
GStash [stash-name]
-- Mimicsgit stash push
, stashing all changes (does not stash files that are not being tracked). Accepts an optional positional argument for the name of the stash.GStashList
-- Opens an fzf window with a list of all stashes. This list gives the users a couple of options to manage their stashesctrl-d
-- Drops the marked stash. This can be applied to multiple stashes using thetab
key to mark each stashctrl-a
-- Pops the marked stash. If multiple stashes are marked with thetab
key, only the first stash will bepop
ped.ctrl-p
-- Applies the marked stash. If multiple stashes are marked with thetab
key, only the first stash will be applied.
My personal recommondation is mapping GStash as :GStash<Space>
, giving you the option of typing in a name after your keystroke, or immediately stashing by typing enter.
The plugin allows configuring the actions and keybindings that are available in the stash list (opened with GStashList
):
" The default configuration
let g:fuzzy_stash_actions = {
\ 'ctrl-d': 'drop',
\ 'ctrl-a': 'pop',
\ 'ctrl-p': 'apply' }
The values to the actions are limited to 'drop'
, 'pop'
, and 'apply'
. If requested, this could probably be updated to allow any git stash
subcommand.
Due to the initial implementation of the plugin and the fact the the maintainer uses an odd keyboard layout, pop
has a default binding to ctrl-a
and apply
has a default binding to ctrl-p
. If this seems backwards to you, this configuration should maybe be a bit more straightforward:
" A more sane configuration
let g:fuzzy_stash_actions = {
\ 'ctrl-d': 'drop',
\ 'ctrl-p': 'pop',
\ 'ctrl-a': 'apply' }