sponsor Vim development Vim logo Vim Book Ad

Crunch : An easier way to perform calculations inside Vim

 script karma  Rating 14/5, Downloaded by 231    Comments, bugs, improvements  Vim wiki

created by
Ryan Carney
 
script type
utility
 
description
Crunch
======

An easier way to perform calculations inside Vim

GitHub
------
The most up to date version of this plugin can be found here:
https://github.com/arecarn/crunch



Overview
--------

Crunch makes calculations in Vim more accessible and loosens Vim's math syntax. Most of Crunch's looser syntax is accomplished by extensive search and replace. Crunch also forces floating point to be used.

Requirements: Vim compiled with +float feature.

Crunch allows you to just type in mathematical expressions without having to worry about the syntax as much.

Usage
-----

:Crunch <args>

Where is some mathematical expression to be evaluated. The result is then available to be pasted from the default register.

:Crunch

Crunch then gives you the following prompt in the command line: Calc >> for you to enter you mathematical expression. The result is then available to be pasted from the default register.

:CrunchLine, :'<'>CrunchLine, or <leader>cl

Crunch Uses the current line or the visually selected lines as the expression(s) and adds the result to the end of the line(s). When the expression(s) changes using :CrunchLine again will reevaluate the line(s)

:CrunchBlock, or <leader>cb

Crunch Uses the current paragraph (block of text starting and ending with an empty line) as the expressions and adds the result to the end of the lines. When a expressions in a paragraph changes using :CrunchBlock again will reevaluate them

Demos
-----

See the Github page for Animated Gif Demos
https://github.com/arecarn/crunch

Make Crunch Better

I'm pretty new to Vim Script so any tips are appreciated. Think you can make Crunch better? Fork it on GitHub and send a pull request. If you find bugs, want new functionality contact me by making an issue on GitHub and I'll see what I can do.

Credits
-------

Sources inspiration and credits for this plugin

http://patorjk.com/ ASCII font courtesy of Patrick Gillespie

https://github.com/gregsexton/VimCalc Greg Sexton Wrote Vimcalc

http://vimrc-dissection.blogspot.com/2011/01/vim-inline-calculator-revisited.html Ihar Filipau wrote most of the tagging code as well as VIM incline calculator

https://github.com/hrsh7th/vim-neco-calc hrsh7th wrote Neco-calc, and inspired the int to float conversion method
 
install details
If you don't have an preferred method, I recommend one of the following plugin managers.

Neobundle
Vundle
pathogen
VAM
 

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
crunch.zip 2.0 2013-11-15 7.3 Ryan Carney - The # has been removed from variable declaration/usage
- evaluate math enclosed in comments.
- :CrunchBlock command evaluates blocks at a time
- various other large and small fixes
crunch.zip 1.0 2013-08-08 7.3 Ryan Carney Initial upload
ip used for rating: 54.204.218.95

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