On Oct 30, 1:38 pm, Bram Moolenaar <[EMAIL PROTECTED]> wrote:
> Ben Schmidt wrote:
> > > 3.  Don't know about v:operator (works for me), the showcmd option
> > > means it could also be v:command or v:operatorcommand (since there is
...
> I'm not quite convinced adding v:operator is useful.  What would help is
> giving a couple of examples how it's used.  Also, in the docs for
> v:operator it would be good to have a few examples of the values.  I
> suppose it can be one char, like "d", but also something longer.  How
> about the count, e.g., when I do "4d"?

Here is a simple example:

function! MyOp(op)
   let cmd = a:op
   echo 'v:count:' v:count 'v:register:' v:register 'v:operator'
v:operator 'you pressed:' cmd
   exec "normal! ".
               \ ((v:count > 0)?(v:count):'').
               \ (v:register=='"'?'':'"'.v:register).
               \ v:operator.
               \ cmd
endfunction

omap w :call MyOp('w')<CR>
omap e :call MyOp('e')<CR>
omap $ :call MyOp('$')<CR>

If you type the following commands:
c$
2yw
"a3de

You will get the following output:
v:count: 0 v:register: " v:operator c you pressed: $
v:count: 2 v:register: " v:operator y you pressed: w
v:count: 3 v:register: a v:operator d you pressed: e

What this provides is all the information to capture what the user
pressed which Vim does not currently support.

In the YankRing case, I will be able to replay what the user typed and
still manage to capture the registers.

This is very useful for me, but I suspect other plugin developers will
also benefit since they can make smarter functions by looking at what
the user has keyed in.

Dave


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui