Convert units to other units quickly and easily from within Vim
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
plugin Move functions into autoload Mar 23, 2018
.gitignore Init commit Mar 20, 2018


This Vim plugin is a tool for converting units to other units. Time, distance, data, power, etc.


:Convert [[value]|[start unit]] {target unit}

To convert in-place the currently visually-selected text which includes a unit, e.g. 500g

:Convert {target unit}

To convert in-place the currently visually-selected text which does not include a unit, e.g. 500, you'll need to specify one:

:Convert {start unit} {target unit}

To insert a unit conversion as a new value after the cursor, give both fields:

:Convert <value><start unit> <target unit>

This plugin will try to be mindful of whether the unit itself is desired when replacing text. That is, if the selected text lacks a unit, the result will be placed without one as well.

Examples of input and results and how they get there:

Selected text Command What it's doing Result
192in :Convert ft units 192in ft 4.166ft
16 :Convert ft in units 16ft in 192
none :Convert 16ft in units 16ft in 192in
any text :Convert 16ft in units 16ft in 192in
12parsecs :Convert hrs units 12parsecs hrs error*

* parsecs are a unit of distance


Several ways to install:

Pathogen Vim plugin manager


cd ~/.vim/bundle
git clone git://

Vundle Vim plugin manager


Add this to the Vundle plugin list in your .vimrc

Plugin 'cspeterson/vim-convert'

Once help tags have been generated, you can view the manual with :help convert.


Customizing the plugin

To set the path to the units command if not in your PATH:

set g:convert_command='/path/to/units'

Customing the Units utility

This plugin uses Units, a GNU unit conversion and calculation program, and so supports any conversions that it supports. As a rule of thumb any unit or shortened unit you think of will probably work.

To list supported units (as defined in Units' definitions.units file) in a split window:


And while the full lowdown on customizing GNU Units may be beyond the scope of this text, here is an example of the sort of statements you could put into $HOME/.units in order to create new definitions or override existing ones:

# re-define `pt` from `pint` to `point` (the typographical unit)
pt      computerpoint
# re-define `pc` from `parsec` to `pica` (the typographical unit)
pc      computerpica


Taking pull requests at

Please code defensively (normal! etc) and try to maintain style, such as there is.


By Christopher Peterson (@cspete)

This plugin relies on the really actually very awesome Units utility from GNU

Images used in the logo art
Vim logo from D0ktorz | SI Units from Dono


Copyright (c) Christopher Peterson. Distributed under The MIT License.