> Brian Golding wrote:
>>
>> Is it possible to abbreviate multiple words. For example to enter a
>> command such as
>>
>> ab "by using" using
>>
>> so that anytime the words "by using" are entered, they will be
>> replaced by just "using"?
>
> Though Ben has already given you the "right" answer that abbreviations can't
> include spaces on the LHS, you might be able to hack it with a horrible
> mapping:
>
> :inoremap by<space>using using
>
> This has the unfortunate side-effect that it thinks you're entering a
> mapping (and doesn't show your typed text) until you've either typed the
> whole thing, or you've disambiguated what you want to type. With the above,
> try entering
Speaking of horrible hacks, I think this one is conceptually worse,
but it doesn't have most of the drawbacks of using a map.
iabbr <expr> using (search('by\_s*using\%#', 'bcW') == 0 ? "using" :
"\<Esc>bcwusing\<Esc>ls")
(That shouild have been all one line, if it was wrapped.) There may
be problems with this that I haven't found, of course, but it seems to
work for my test cases. Not that I'd recommend it, anyway... :-)
~Matt
No comments:
Post a Comment