Ⅰ. 插件描述
Vim plugin: Perform calculations on numbers in text, calculator with regex supportⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'bimbalaszlo/vim-numutils'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'bimbalaszlo/vim-numutils'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'bimbalaszlo/vim-numutils'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/bimbalaszlo/vim-numutils
Ⅳ. 文档说明
= NumUtils
calculator with regex support
Did you ever want to manipulate a lot of data in text files? Add an offset
to the axes in G-code, calculate the finances, or just renumber the
chapters in the table of contents? With this plugin you can do the
calculations with regular expression support!
- https://gitlab.com/bimlas/vim-numutils (main repository)
- https://github.com/bimlas/vim-numutils (mirror, please star if you like it)
- http://www.vim.org/scripts/script.php?script_id=4634 (please rate if you using it)
Please feel free to send me a mail if you have a good idea, or found a
- If you think the plugin does something else that you want, send me
- lines to manipulate, the task that the plugin should do and the
command that you used for, and i try to find and fix the bug.
== Examples
NumUtilsAdd, NumUtilsSub, NumUtilsMul, NumUtilsDiv
With the built-in commands you can do the basic stuff: addition,
subtraction, multiplication and division. By default the commands
will be called on the line where the cursor stays, but you can use:range, :global, or linewise-visual to give a range as you do
when you using :subtitute for example.
A basic usage is for example add 10 to every number prefixed by X on this
line:
[source]
X123 Y456 Z789 X100To do it, call this:
[source]
:NumUtilsAdd 10, 'X'
... and you will get this:
[source]
X133 Y456 Z789 X110Another example (add 2 to the number after star_ and to the number after
another number):
[source]
.star_10 {
background: url(stars.png) no-repeat 0 0;
}
:NumUtilsAdd 2, 'star_!NUM!', ':NUM: !NUM!;$'
.star_12 {
background: url(stars.png) no-repeat 0 2;
}There is another useful feature (add first and second submatch to value of
_!NUM!_):
[source]
100|20|3
:NumUtilsAdd [1,2], '(:NUM:)|(:NUM:)|!NUM!'
100|20|123== Install
Manually:
https://github.com/bimlas/vim-numutils/archive/master.zip[Download]
and unzip the subdirectories into '~/.vim'.
Don't forget to regenerate helptags:
[source]
:helptags ~/.vim/doc
https://github.com/tpope/vim-pathogen[Pathogen]:
... into '~/.vim/bundle' (or to your specific pathogen directory).
Don't forget to regenerate helptags:
[source]
:Helptags
https://github.com/gmarik/Vundle.vim[Vundle]:
Add these lines to your '.vimrc' after call vundle#rc():
[source]
Plugin 'bimlas/vim-numutils'
Open vim again, then call :PluginInstall