A Mercurial Wrapper For Vim

Lawrencium is a Mercurial wrapper for Vim, inspired by Tim Pope’s Fugitive. It loads up when you edit a file inside a Mercurial repository — anything from a committed file to a new file, even ignored files and files stored in the .hg directory.


When Lawrencium is active, you get access to several commands that let you work with your revision history without having to leave your text editor.


The recommended method to install Lawrencium is to use Pathogen, also from Tim Pope:

cd ~/.vim/bundle
hg clone https://bitbucket.org/ludovicchabant/vim-lawrencium

You can then update the help tags with :call pathogen#helptags() and browse Lawrencium’s help pages with :help lawrencium.

You can alternatively download the latest snapshot as a ZIP archive and extract it yourself in the bundle directory, or any other place where Vim will pick it up.

The source code for Lawrencium is available on Github and Bitbucket.

Quick Start

Open a file from one of your Mercurial repositories.

:e ~/Work/Project1/src/foo.py

Work on it for a bit, then open another file, this time using Hgedit and a repository-relative path:

:Hgedit src/bar.py

Take advantage of the auto-completion when typing the path!

Work on that other file too, then compare it to the parent revision version:


This would split the current window vertically, and show your changes using a regular Vim diff buffer, so you can use usual stuff like ]c and [c.

Close the parent revision version (:q) and continue working.

At any moment, you can run a Mercurial command and get a quick glance at its output:

:Hg log --limit 5 src/blah/bleh

Note how auto-completion will help you with all the built-in commands and their options! Any other parameter will auto-complete with repository-relative paths.

Once you’re happy with your work, bring up the status window:


You can see the difference between modified files and their parent revision version easily by moving the cursor to the appropriate line and hitting <C-V>. You can also do an addremove by using <C-A> (use the selection mode to add/remove several files at once!). Those mappings are defined for you but you can of course change them (they map to :Hgstatusvdiff and :Hgstatusaddremove).

Now it’s time to commit. While still in the status window, remove all mentions of files you don’t want to commit, and hit <C-S>. Write your commit message, then :wq, and you’re done!

You can check that everything went fine by having a quick look at that latest commit:

:Hg tip

You can also commit faster with the :Hgcommit command of course!

That’s it for now. You can open the help file with :help lawrencium, and post your questions and problems either in the Github issue tracker or the BitBucket issue tracker.