Sunday, November 24, 2013

Re: vim rpn calculator

On 2013-11-24, Bee wrote:
> On Sunday, November 24, 2013 9:58:15 PM UTC-8, Gary Johnson wrote:
> > On 2013-11-24, Bee wrote:
> > > > Type
> > > > 5 5 + 3 * p
> > > > on a line in vim, leaving the cursor on that line. Then
> > > > !!dc<enter>
> > >
> > > I tried that and got an error:
> > > E34: No previous command
> > From that error I'd say you typed
> > :!!dc
> > and Enter. Don't use the :. Just type
> > !!dc
> > and Enter.
>
> Ah... thank you, that does work, but replaces the line with the result.
> I would prefer something like:
>
> 5 5 + 3 * p = 30

Here are a couple of mappings that will produce that result. Just
type

,=

in either insert or normal mode on the line with the expression.

imap ,= <Esc>0y$!!dc<CR>I = <Esc>0PA
nmap ,= 0y$!!dc<CR>I = <Esc>0P

Regards,
Gary

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