Home

Awesome

crunch

crunch makes calculations in Vim more accessible by providing an operator to evaluate mathematical expressions, loosening Vim's math syntax, and forcing integers into floating point numbers.

Usage

ModeKey MappingDescription
normalg={motion}Evaluate the text that {motion} moves over
normalg==Evaluate the current line
visualg=Evaluate the highlighted expressions

Requirements


Math With Looser Syntax

The following chart shows the looser math syntax provided with crunch, compared to the default math syntax.

FeatureWith crunchWithout crunch
Implied Multiplication
cos(0)cos(0) = 1cos(0)*cos(0) = 1.0
2sin(1) = 1.6829422*sin(1) = 1.682942
sin(1)2 = 1.682942sin(1)*2 = 1.682942
(2*3)(3*2) = 36(2*3)*(3*2) = 36
2(3*2) = 122*(3*2) = 12
Integer to Float Conversion
1/2 = 0.51.0/2.0 = 0.5
.25*4 = 10.25*4 = 1.0
Decimals w/o Leading Zeros
.5/2 = 0.250.5/2 = 0.25
.25*4 = 10.25*4 = 1.0
Removed Zeros In Result
0.25*4 = 10.25*4 = 1.0
pow(2,8) = 256pow(2,8)= 256.0