Monday, February 6, 2012

Re: Help me improve the inline calculator

On Feb 6, 1:29 am, oversky <mail...@gmail.com> wrote:
> However, I don't know how to make it deal with such equation:
>
> (2+3)^(5-3)
>
> because regexp can't find the matching bracket.
> Is there a internal function acting like v_ib
>

You could USE vib or yib or similar if you wanted, with a :normal
command, although this will clobber a register (I'm not sure whether
you care about that, I normally don't if it makes things easier).

Barring that, you may be able to use the searchpair or searchpairpos
functions.

Since this is all on one line, the other thing I've done in the past
for nested pairs of characters, is to parse the text in a loop or
recursive function, handling a single level of parentheses on each
pass. It's easy enough to match the innermost level of a nested set of
parentheses, using something like ([^()]\{-}). You could calculate the
innermost level of parentheses and replace it with the value, and
repeat until there are no more parentheses in the string.

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

No comments: