2013. november 24., vasárnap 23:14:47 UTC+1 időpontban Bee a következőt írta:
> From (linux or mac) vim I can use 'dc' a command line rpn calculator as:
>
> :!dc '-e 5 5 + 3 * p'
>
> It prints the result on the command line... THEN returns to vim.
>
> How do I return the value to vim?
>
> Is there an rpn calculator for vim?
>
> Bill
You can use the NumUtils ( http://www.vim.org/scripts/script.php?script_id=4634 ) plugin for this. Write this function to your .vimrc:
function Solver( args, NUM, matches )
return eval( a:matches.sub[ 1 ] )
endfunction
Copy the equation in to a buffer, for example:
( 5 + 5 ) * 3 = 0
... set the cursor on it, then type this in to the command prompt:
:NumUtilsCall 'MyFunc', '', '\(.*\) = !NUM!'
The result will be after the equal sign:
( 5 + 5 ) * 3 = 30
It's a portable solution, because it uses the vim to calculate the equation and you can use the builtin functions in it.
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Tuesday, November 26, 2013
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment