HowMuch README file
__ __ __ ___ __ ___
/ / / /___ _ __/ |/ /_ _______/ /_ /__ \
/ /_/ / __ \ | /| / / /|_/ / / / / ___/ __ \ / _/
/ __ / /_/ / |/ |/ / / / / /_/ / /__/ / / / /_/
/_/ /_/\____/|__/|__/_/ /_/\__,_/\___/_/ /_/ (_)
- A Vim calculator for visual selections
(http://www.vim.org/scripts/script.php?script_id=4761)
Table of contents
(toc is generated by ghtoc)
Introduction
HowMuch
is a Vim plugin to calculate visual selected mathematical formulars (vim or bc expressions). It will add the result(or replace the selected expressions) in the current edit text. For details check next section: Features
Features
- Supports all visual selection modes (char-/line-/block-wise)
- Supports two output formats:
- append result with/out
=
after the expression - replace the selected expressions with result
- append result with/out
- Supports sum total result in line-(
V
) and block-wise (Ctrl-V
)selection - You can create custom mapping to invoke
HowMuch
- Evaluation "Engines" (The expression evaluator)
HowMuch
supportsGNU bc
,python
andnative vim
expressions evaluation engines,- You can choose which engine should be used to evaluate current visual section.
- You can define the order of the engines, and let
HowMuch
do evaluation automatically. E.g. ifbc
fails, tryvim
again. - You can add your own engines or modify the built-in engines. read documentation for details.
!Please read plugin documentation (HowMuch-config section) for options, mappings
Command
HowMuch
can be invoked by command as well. There is a :HowMuch [flags]
command. We can first visual select the expressions, then for example do :HowMuch s=
to append result with =
sign to the end of selection, also add a sum at the bottom of selection. :HowMuch command only work for 'autoCalc' mode Read :h :HowMuch
for the available flags.
Examples & Screencasts
Examples and screencasts would be the best way to explain how does HowMuch
does its job. In the demo section, only Auto-Calc will be demoed. The calculation can be done by certain engine. E.g
<leader>b?
forbc
<leader>v?
forvim
<leader>p?
forpython
Details please check plugin documentation.
All demos were made with following settings.
"The scale of the result:
let g:HowMuch_scale = 2
"the engine order for auto-calculation
let g:HowMuch_auto_engines = ['bc', 'vim', 'py']
Auto-Calc Demo
Auto-calc will evaluate each expression with each engine in turn, taking order from g:HowMuch_auto_engines
, till a result without error comes out. If all engines give Err
. E.g an expression like ##+foo
, result is Err
.
As long as there was an Err
, the result of sum
would be Err
Demo 1:
- block-wise selection (
Ctrl-V
) - Append result after each expression, separated with '=',
- default mapping:
<Leader>?=
Demo 2:
- block-wise selection (
Ctrl-V
) - replace selected expressions with result
- default mapping:
<leader><Leader>?
Demo 3:
- block-wise selection (
Ctrl-V
) - append result after each expressions (with Err)
- do sum (with Err)
- default mapping:
<Leader>?s
Demo 4:
- block-wise selection (
Ctrl-V
) - replace selected expressions with result
- do sum
- default mapping:
<Leader><Leader>?s