Evaluate text as a math expression and replace it with the result.
Using vim-plug:
Plug 'm1foley/vim-expresso'
g=
after selecting text replaces it with the result.
g=
with a motion. For example,g=$
evaluates text from the cursor to the end of the line.g==
evaluates the current line.
- With a range like
:1,7Expresso
Expresso uses Vim expressions, so it has the same limitations of @=
, the expression register. If none of the numbers have a decimal, it evaluates to a whole number: 3/2
= 1
. To force a Float
conversion, add a decimal to one of the numbers: 3/2.0
= 1.5
- crunch is a more powerful & expressive math plugin, and gets around the
Float
conversion issue.
MIT