Giter VIP home page Giter VIP logo

howmuch's Introduction

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
  • 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 supports GNU bc, python and native 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. if bc fails, try vim 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? for bc
  • <leader>v? for vim
  • <leader>p? for python

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>?= demo1

Demo 2:

  • block-wise selection (Ctrl-V)
  • replace selected expressions with result
  • default mapping: <leader><Leader>? demo2

Demo 3:

  • block-wise selection (Ctrl-V)
  • append result after each expressions (with Err)
  • do sum (with Err)
  • default mapping: <Leader>?s demo3

Demo 4:

  • block-wise selection (Ctrl-V)
  • replace selected expressions with result
  • do sum
  • default mapping: <Leader><Leader>?s demo4

Demo 5:

  • block-wise selection (Ctrl-V)
  • Append result after each expression, separated with '=',
  • do sum
  • default mapping: <Leader>?=s demo5

howmuch's People

Contributors

lukelbd avatar sk1418 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

howmuch's Issues

Suggestion: default mappings to <leader>hm

Jeje this plugin is awesome! ๐Ÿ˜Ž

Let me suggest super easy to remember mappings:

vmap <leader>hm <Plug>AutoCalcAppend             
vmap <leader>hms <Plug>AutoCalcAppendWithSum      
vmap <leader>hme <Plug>AutoCalcAppendWithEq       
vmap <leader>hmse <Plug>AutoCalcAppendWithEqAndSum 
vmap <leader>hmr <Plug>AutoCalcReplace            
vmap <leader>hmrs <Plug>AutoCalcReplaceWithSum     

calculate time

Hi! I'm looking at this nifty plugin, looking at places I might use it, and realize that a number of the columns I'd like to see calculated are durations. (specifically taskwarrior(.org) reports, and as seen in vim-taskwarrior (https://github.com/farseer90718/vim-taskwarrior)
Is there a chance that HowMuch can be convinced to add or calculate time?

Can't use python libraries

Hi -

Thanks! This will be very useful. I would like to be able to calculate statistics such as the mean, std etc on columns of data. Is that possible? I tried using python's numpy to calculate a mean on a single line of data but I don't seem to be able to even do that. Thanks again,

Shawn

python2 is obsolete

As per a fresh install of vim 8.2 on Fedora 31 this is compiled without the support for python2 because python2 get to end-of-life by the first of January 2020.

As a result your python engine doesn't work anymore.

A easy patch is to change

  • line 302 'python' to 'python3'
  • line 308 'python' to 'python3'
    in autoload/HowMuch.vim

I HTH

Just visualize the sum

Hello!

Thank you for the usefull plugin.
Actually, I would like just calculate the sum without modifying the text.

I have modified the HowMuch function like this
redraw! | echo 'Sum: ' . (type(total)==type("") ? total : HowMuch#float_to_str(total))

Maybe it will be usefull to add this option into plugin.

Best regards,
Artem

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.