On May 16, 6:39 pm, "John Beckett" <[email protected]> wrote:

> I think it would be good to start again with a statement of what problem
> needs to be solved. I'm wondering why 'ihs' appears twice, and what would
> you want the user command to be?
>
> How about a simple example showing what you would like to enter
> and what it should do.

OK There is a form of the abbreviation command like this:

    ab <expr> string expression

For this purpose I want to use this function for the expression:

function! ABB(lhs, rhs)
    if getcmdtype() == ':'
        return a:lhs
    else
        return a:rhs
    endif
endfunction

So after I execute the command,

       ab <expr> howard ABB("howard","schwartz")

each time I type howard it will be replaced by schwartz, except when
I am on the  : command line. In that case, howard will not be replaced
by
schwartz.

I want to write a user defined command that does the same
thing as the above, ab, command. Let's call the user command Ab. Then,

      Ab howard schwartz

will have the same effect as executing the command,

      ab <expr> howard ABB(howard,schwartz)

The string, 'howard', must occur twice in the ordinary abbreviation
command
above - once as the initial string, and again as the first argument of
the
function ABB().

So I must, extract `howard' from the expressions <args> or <f-args>
that
evaluate to all arguments of a user command.

I know this will not work, but here is a sample command that might do
the
trick:

       command! =nargs=2 ab <expr> matchstr(<args>,"^.* ") ABB(<f-
args>)

if <args> evaulated to "howard Schwartz" than the matchstr function
might
return the first characters followed by a blank (which would be
"howard ")

I want to define a user command like that that will really work! Why?
Because,

        Ab howard schwartz

is a lot simpler than,

        ab <expr> howard ABB(howard,schwartz)











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

Reply via email to