vimagit
Ease your git workflow within vim.
From a very single vim buffer, you can perform main git operations in few key press. To name a few:
- Visualize all diffs in your git repository.
- Stage file, hunks or even just parts of a hunk using a single key press.
- Write or amend your commit message and commit in the same buffer.
Take a look at TL;DR to start using it immediately.
Some screencasts:
- A simple asciicast
- A commented video presenting vimagit (thank you Mike Hartington!)
This workflow is 100% inspired from magnificent emacs Magit plugin.
Outstanding features
- Preview all your git changes in one unique buffer, folded at hunk level.
- Interactively stage/unstage/discard changes with one key press.
- Stage/unstage at file/hunk/line level.
- Write the commit message in the same buffer.
- From a hunk in magit buffer, jump to the file at the diff position.
- 100% VimL plugin, no external dependency (except git of course).
- Enhanced by external plugins: vim-gitgutter vim-airline
- Stable. All features are tested in continuous integration.
More to come:
- Add a push function, taking care if needed about the remote repository and branch #24 .
- Handle commit fixup! and squash!, with a smart git log popup #23 .
- Handle stash: add, pop, apply, drop #26 .
- Stage multiple hunks or file by visually selecting them #83 .
- Go through history, cherry-pick changes.
- Make vimagit more efficient for huge repositories, with a lot of diffs.
- Something is missing? Open an issue!
Why should I use vimagit, there are already plethora git plugins for vim?
- fugitive is a very complete plugin, with a lot of functions. I use it for years, and it is a fundamental tool in my workflow. But visualize your changes and staged them in broad number of files is really a pain.
- vim-gitgutter is very well integrated into vim, but without the ability to commit stages, it stays an informational plugin.
TL;DR
This is the minimal required set of command you must know to start playing with vimagit. See Mappings for a complete description.
To simply test vimagit, modify/add/delete/rename some files in a git repository and open vim.
-
:Magit
Open magit buffer with :Magit command. -
<C-n>
Jump to next hunk with<C-n>
, or move the cursor as you like. The cursor is on a hunk. -
S
While the cursor is on an unstaged hunk, pressS
in Normal mode: the hunk is now staged, and appears in "Staged changes" section (you can also unstage a hunk from "Staged section" withS
). -
CC
Once you have stage all the required changes, pressCC
.- Section "Commit message" is shown.
- Type your commit message in this section.
- To commit, go back in Normal mode, and press
CC
(or:w
if you prefer).
You just created your first commit with vimagit!
Installation
This plugin follows the standard runtime path structure, and as such it can be installed with a variety of plugin managers:
- Pathogen
git clone https://github.com/jreybert/vimagit ~/.vim/bundle/vimagit
Remember to run :Helptags to generate help tags - NeoBundle
NeoBundle 'jreybert/vimagit'
- Vundle
Plugin 'jreybert/vimagit'
- Plug
Plug 'jreybert/vimagit'
- VAM
call vam#ActivateAddons([ 'jreybert/vimagit' ])
- manual
copy all of the files into your ~/.vim directory
Usage
Modes
vimagit buffer has modes. Mappings may have different behavior, depending on current mode and curosr position.
For the moment, vimagit counts only two modes.
Stage mode
This is the default mode. In this mode, you can stage and unstage hunks, refresh vimagit buffer...