Ⅰ. 插件描述
Convert units to other units quickly and easily from within VimⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'cspeterson/vim-convert'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'cspeterson/vim-convert'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'cspeterson/vim-convert'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/cspeterson/vim-convert
Ⅳ. 文档说明
convert.vim
This Vim plugin is a tool for converting units to other units. Time, distance,
data, power, etc.

Usage
: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
Installation
Several ways to install:
Pathogen Vim plugin manager
cd ~/.vim/bundle
git clone git://github.com/cspeterson/vim-convert.gitVundle Vim plugin manager
Add this to the Vundle plugin list in your .vimrc
Plugin 'cspeterson/vim-convert'And install with:
vim +PluginInstallOnce help tags have been generated, you can view the manual with:help convert.
Customization
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:
:UnitsAnd 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 computerpicaContributing
Taking pull requests at https://github.com/cspeterson/vim-convert
Please code defensively (normal! etc) and try to maintain style, such as
there is.
Credits
By Christopher Peterson (@cspete)
This plugin relies on the really actually very awesome Units utility from GNU
Images used in the logo art<br/>
Vim logo from D0ktorz | SI Units from Dono
License
Copyright (c) Christopher Peterson. Distributed under The MIT License.