https://github.com/m1foley/vim-expresso
Easily perform math calculations from text
https://github.com/m1foley/vim-expresso
vim
Last synced: 4 months ago
JSON representation
Easily perform math calculations from text
- Host: GitHub
- URL: https://github.com/m1foley/vim-expresso
- Owner: m1foley
- License: mit
- Created: 2016-03-17T23:05:38.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2024-08-29T04:53:26.000Z (almost 2 years ago)
- Last Synced: 2025-10-25T01:41:39.531Z (8 months ago)
- Topics: vim
- Language: Vim Script
- Homepage:
- Size: 11.7 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
expresso.vim
============
Evaluate text as a math expression and replace it with the result.

Installation
------------
Using [vim-plug](https://github.com/junegunn/vim-plug):
```vim
Plug 'm1foley/vim-expresso'
```
Usage
-----
### Visual mode
- `g=` after selecting text replaces it with the result.
### Normal mode
- `g=` with a motion. For example, `g=$` evaluates text from the cursor to the end of the line.
- `g==` evaluates the current line.
### Command mode
- With a range like `:1,7Expresso`
Limitations
-------------
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`
Similar Projects
----------------
- [crunch](https://github.com/arecarn/crunch.vim) is a more powerful & expressive math plugin, and gets around the `Float` conversion issue.
License
-------
MIT