Skip to content
Adria Arrufat edited this page Dec 6, 2022 · 10 revisions

bc stands for "basic calculator"

https://en.wikipedia.org/wiki/Bc_(programming_language)

Incrementing / decrementing numbers

define-command -hidden -params 2 inc %{ try %{
    evaluate-commands %sh{
        [ "$1" = 0 ] && count=1 || count="$1"
        printf '%s%s' 'exec h"_/\d<ret><a-i>na' "$2($count)<esc>|{<space>cat<semicolon>echo<semicolon>}|bc<ret>"
    }
} catch %{
    execute-keys l
}}
map global normal <c-a> ': inc %val{count} +<ret>'
map global normal <c-x> ': inc %val{count} -<ret>'

See plugin https://gitlab.com/Screwtapello/kakoune-inc-dec

Creating a quick math prompt

map global normal = ': prompt math: %{exec "a%val{text}<lt>esc>|{ cat; echo; }|bc<lt>ret>"}<ret>'

See plugin https://github.com/alexherbo2/bc.kak

Clone this wiki locally