Wednesday, November 27, 2013

Re: vim rpn calculator

After reading :help :put again and again,

> :[line]pu[t] [x]
> Put the text [from register x] after [line] (default current line).
> ...
> The register can also be '=' followed by an optional expression.
> The expression continues until the end of the command.
> You need to escape the '|' and '"' characters to
> prevent them from terminating the command.
> Example:
> :put ='path' . \",/test\"


I reduced the RPN calc to a one line imap:
(comments best viewed in monospaced font)


imap ,= <esc>:put =system('dc \"-e2k'.getline('.').'n\"').' '<cr>A
" ''''' | | || | | | | | | +eol
" ''''' | | || | | | | | +run imap
" ''''' | | || | | | | +concat space
" ''''' | | || | | | |
" ''''' | | || | | | +concat print command
" ''''' | | || | | +concat calc text
" ''''' | | || | +precision
" ''''' | | || +build shell command
" ''''' | | |+output shell command
" ''''' | | +expression register
" ''''' | +result after current line
" ''''' +normal


Now I do not need to prevent screen redraw
and do not need to save/restore a register.

Bill

--
--
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.

No comments: