Quick and easy unit conversions within Vim (vim-convert)
Header image bits: Vim logo from D0ktorz and SI Units from Dono
Editing some varieties of documents I noticed myself jumping into a browser or terminal often to do unit conversion. But no longer! Vim-convert is a plugin I made for Vim that allows easy unit conversion from a simple command.
The command
1 |
:Convert [[value]|[start unit]] {target unit} |
Some usage examples
To convert in-place the currently visually-selected text which includes a
unit, e.g. 500g
1 |
: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:
1 |
:Convert {start unit} {target unit} |
To insert a unit conversion as a new value after the cursor, give both fields:
1 |
:Convert <value><start unit> <target unit> |
To cause an error because parsecs are a unit of distance:
1 |
:Convert 12parsecs hours |
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.
Installation instructions and other details in the README.