sponsor Vim development Vim logo Vim Book Ad

NumUtils : calculator with regex support

 script karma  Rating 4/1, Downloaded by 187    Comments, bugs, improvements  Vim wiki

created by
Laszlo Bimba
 
script type
utility
 
description
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!

Please feel free to send me a mail if you have a good idea, or found a
bug. If you think the plugin does something else that you want, send me
the 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:

    X123 Y456 Z789 X100

To do it, call this:

:NumUtilsAdd 10, 'X'

... and you will get this:

    X133 Y456 Z789 X110

Another example (add 2 to the number after star_ and to the number after
another number):

    .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!):

    100|20|3

:NumUtilsAdd [1,2], '\(:NUM:\)|\(:NUM:\)|!NUM!'

    100|20|123
 
install details
Open in vim then run
:so %

... or use Vundle:

Add these lines to your .vimrc after 'call vundle#rc()':

Plugin 'bimbalaszlo/vim-numutils'

Open vim again, then call ':PluginInstall'

Please rate if you using it!
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
NumUtils.vmb 1.0 2013-06-25 7.3 Laszlo Bimba Initial upload
ip used for rating: 54.90.233.153

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
SourceForge.net Logo