Monday, November 25, 2013

Re: vim rpn calculator

On 2013-11-25, Bee wrote:
> Thank you Gary, that is very clever and works great.
>
> I have commented and add setting precision
> best viewed in a monospaced font.
> Please let me know if I commented correctly.
>
> imap ,= <esc>I2k <esc>0y$!!dc<cr>I = <esc>0PA
> " ''''' | |||| | ||+append result to eol

The purpose of the A is put the user interface back into insert mode
with the cursor at the end of the line.

> " ''''' | |||| | |+put calc
at sol

> " ''''' | |||| | +back to sol
> " ''''' | |||| +insert " = " at sol
> " ''''' | |||+pass calc to dc
and replace current line
with results

> " ''''' | ||+eol

The $ is part of the yank command, not a separate motion command.
It wasn't clear to me from the comment whether you understood that.

> " ''''' | |+yank calc to eol
> " ''''' | +back to sol
> " ''''' +insert precision at sol

It might help your understanding if you step through the right side
of that mapping one key at a time, replacing the <>-notated keys
with their real key equivalents. Then you can watch each change as
it happens. I often do that when I can't figure out what a mapping
is doing by just looking at it.

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:

Post a Comment