ab "by using" using
so that anytime the words "by using" are entered, they will be
replaced by just "using"?
Thanks
Brian Golding
Nope.
:help abbreviations
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
This is done by using taxes and by usury.
you get the "This is done " portion, and then the "by usin"
flickers as you type it, until you get to the "g", at which point
it "expands" the mapping to just "using", and then when you start
typing the "by usury", you get the "by us" flickering until the
"u" disambiguates and you see the "by usu".
As stated: an ugly hack.
When I need to flag words/phrases I prefer not to use (in my
"critiqued" works, I tend to avoid forms of "to be"), I use a
:match command like
:match Error /\<\(be\|am\|is\|are\|was\|were\|...\)\>/
so they jump out at me and I can rephrase them. So in your case,
I'd use
:match Error /\<\(by using\|by \w\+ing\|...\)\>/
with any other phrases you want to revise.
-tim
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
<shudders>
Like obfuscated C contests, that mapping is art, but a bit
impenetrable like modern art. :)
-tim
You can check out Kana's ctxabbr plugin (actually an autoload script):
http://vim.sf.net/scripts/script.php?script_id=2514
The script serves a slightly different purpose, but the following works
for me:
:call ctxabbr#define('using', "\<C-W>using", '<by')
This defines a "context sensitive" abbreviation. It works like
:inoreabbrev using <C-W>using
but expands only when "by" is found to the left.
--
Andy
On Jan 7, 3:46 am, Andy Wokula <anw...@yahoo.de> wrote:
> You can check out Kana's ctxabbr plugin (actually an autoload script):http://vim.sf.net/scripts/script.php?script_id=2514
>
> The script serves a slightly different purpose, but the following works
> for me:
>
> :call ctxabbr#define('using', "\<C-W>using", '<by')
>
> This defines a "context sensitive" abbreviation. It works like
>
> :inoreabbrev using <C-W>using
>
> but expands only when "by" is found to the left.
>
Very nice solution! Shouldn't there be two \<C-W> commands, though, to
also remove the word "by"?