Advent 2023: (n)vim Plugins: vim-fugitive

Because I've spent most of my professional life coding, I've also spent a lot of time using source control. I've been using specifically git for many years (even pre-dating the Zend Framework migration from Subversion). While I typically use a terminal multiplexer (for me, that's tmux; for others, that might be screen), and can move to another pane or create one quickly in order to run source control commands, doing so interrupts flow.

That's where vim-fugitive comes into play.

What does it solve?

Fugitive integrates with git, plain and simple. It exposes a number of commands and functions that allow you to do common operations quickly, but also has some deeper bindings to allow doing more complex things such as viewing a file from previous commits, or performing a diff between the staged and working version, or using git blame within vim.

How do I use it?

Admittedly, I use a very small subset of what Fugitive provides.

On a daily basis, I use :Gwrite to stage changes, and :G to view the status of the working tree. When in the status view, I often use cc to commit changes, which splits open a pane for writing the commit message. I also use :GRemove when I want to remove a file from the tree.

Something else that has come in handy when reviewing code with others: :GBrowse can open the file in the canonical repository, using the visual selection as the line range, allowing you to quickly share a link to specific code to review.

Final Thoughts

This plugin does exactly what it says on the tin. I love the fact that it integrates with the underlying git command, as that follows the Unix Philosophy of doing one thing well, and piping out to other processes to perform complex behavior. For me, the fact that I can stay directly within my editor and still get full access to git when needed is tremondously powerful.