>> Well, I can see that you get the information, but this is not really a
>> useful real-world example. Think of a user that wants to get something
>> done for which v:operator is needed. And for which there is no other
>> solution.
>
> Here's a somewhat naively implemented example where a custom text-object is
> defined that allows you to operate on a function name whether the cursor is
> on the
> name itself or on its arguments. You can yank with yF, change with cF,
> uppercase
> with gUF, etc. I can't think of any other way to do this, or more complicated
> language-based custom text-object definition--e.g. yank/change a whole
> conjunction
> or disjunction in a logic language, yank or change the condition of an 'if'
> or
> 'while' loop from anywhere within its body. Some of these would be more
> useful
> than others, of course, but there are a lot of real world possibilities, I
> think.
A better one:
:onoremap F <Esc>:call OperateFunctionName()<CR>
:function! OperateFunctionName()
: let save_count = v:count
: let save_op = v:operator
: let save_reg = v:register
: while search('\(\%#\i\|\i\s*\%#\)\i*\s*(','ce',line('.')+1) == 0
: if searchpair('(','',')','bW') == 0
: normal "\<Esc>"
: return
: endif
: endwhile
: exe "normal \<BS>\"_yiw"
: exe 'normal "'.save_reg.(save_count>0?(save_count):'').save_op.'e'
:endfun
Send instant messages to your online friends http://au.messenger.yahoo.com
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---