This repository has moved to https://git.navicore.tech/navicore/bc.nvim.
The GitHub copy is archived and no longer maintained.
A simple Neovim plugin to evaluate mathematical expressions using bc in markdown and telekasten files.
Add to your lazy.nvim plugin specification:
"navicore/bc.nvim"Or in your full lazy setup:
require("lazy").setup({
-- your other plugins...
"navicore/bc.nvim",
-- more plugins...
})use 'navicore/bc.nvim'Plug 'navicore/bc.nvim'- Open a markdown or telekasten file
- Visually select a mathematical expression (e.g.,
2 * (33 - 1)) - Run
:Bcor:'<,'>Bc - The selection will be replaced with the expression and its result (e.g.,
2 * (33 - 1) = 64)
The plugin supports currency and comma formatting:
$symbols are preserved and the result uses 2 decimal places- Comma separators in numbers (e.g.,
10,000) are preserved in the result
Examples:
2 * $5→2 * $5 = $10.00$100 / 3→$100 / 3 = $33.332 * 10,000→2 * 10,000 = 20,000$1,000 + $500→$1,000 + $500 = $1,500.00
The output type is inferred from the input:
- Integers only → integer result (e.g.,
10 / 3 = 3) - Any float in input → float result matching max decimal places (e.g.,
10.0 / 3 = 3.3) - Currency ($) → always 2 decimal places (e.g.,
$10 / 3 = $3.33)
To get decimal results from integer division, use a float in the input: 10.0 / 3 instead of 10 / 3.
- Neovim 0.7+
bccommand-line calculator (usually pre-installed on Unix-like systems)
- Only works in markdown or telekasten files (filetype must be
markdownortelekasten) - Uses
bcsyntax, so expressions must be validbcinput