Hello,
* On Fri, Jun 30, 2006 at 09:03:57AM +0800, Dr Bean <[EMAIL PROTECTED]> wrote:
> > > Is there a way to not insert a space based on context around the
> > > cursor so that if the text before cursor is [xxx, or (xxx, no space
> > > will be inserted?
>
> > He used the function InsertIfNotAfter() I define in my C++ ftplugin
> > cpp_set.vim available in lh-cpp.tar.gz [1].
> > In your case, I guess it will look like:
>
> > inoremap <silent> ,
> > \ <c-r>=InsertIfNotAfter(',', ', ', '[[(][^]]\+')<cr>
>
> Just for my own benefit, and to refresh my memory about what this
> means:
>
> It's a mapping to add a space after the comma, but only when the comma
> is not preceded by something the regex matches.
I must admit I never remember which parameter is expanded when.
If the pattern is matched, we expand the first parameter. The second
otherwise.
> What the regex matches is an opening bracket or parenthesis followed
> by a number of non-closing-bracket characters.
>
> Shouldn't the closing parenthesis be included also in the regex?
> '[[(][^])]\+'
Of course. You're right.
--
Luc Hermitte
http://hermitte.free.fr/vim/