I recently started using Git for my local revision control. Since I spend about 90% of my coding time inside the Vim editor, I went looking for a plugin that would make Vim play nice with Git. In this article I present two different vim plugins and explore their feature-set via screenshots.

My expectations from a git plugin were rather simple.

Display the active git branch of current file.

Switch between different branches, without quitting Vim.

Multi-platform support.

I found two competing plugins that satisfied my needs: git-branch-info.vim and git.vim.

This plugin was designed to display the current branch info in the vim status line.

set laststatus=2 " Enables the status line at the bottom of Vim set statusline=%{GitBranchInfoString()}

In addition to the current branch info, it can also list all the branches in the current git repo through a menu (only in gVim) and allows to checkout/fetch a particular branch.

One caveat of this plugin is it’s designed with a Linux user in mind and it didn’t work in windows in its original form. Since it was project hosted on Github, I decided to fork it and make a windows version of the plugin. The windows version can be downloaded from the project’s windows fork.

Git.vim is a more comprehensive plugin that allows the user to perform a lot more Git operations from within the Vim environment. The github home page for this plugin has a list of all the functionalities available through this plugin.

The name of the function called to set the status line is GitBranch(). So the lines added to .vimrc will be,

set laststatus=2 set statusline=%{GitBranch()}

But unfortunately there is a bug in the GitBranch() function. Once again Github to the rescue, the project is forked and the bug fixed fork can be downloaded here. A pull request is submitted to the author to fix this bug.

Some of the other features of this plugin are showcased below. This plugin comes with syntax files that hightlights the git log, git diff and git commit messages. The syntax highlighting can be seen in the screenshots shown below.

GitCommit

:GitCommit opens a split window to enter the log message and commits the current file to the repository. If no files are staged to the index, it will automatically use git commit -a option to stage all the changed files and commit them to the repository.

GitDiff

:GitDiff opens a split window with the output of the git diff command on the current file.

GitLog

:GitLog to show the commit log of the current file.

GitBlame

:GitBlame Shows the changes made to a file on a line-by-line basis, by displaying the name of the user next to each line in a vertical split.