On Mon, Sep 25, 2006 at 08:29:02PM +0200, Kim Schulz wrote:
> On Sat, 23 Sep 2006 17:08:39 +0200
> Luc Hermitte <[EMAIL PROTECTED]> wrote:
> [snip]
> 
> > > I guess it is in the mark for place of last change, but I just cant
> > > get iabbrev to execute my movement command (other than using <left>
> > > <right> <up> <down>). Is there any way to do this?
> > 
> > I finally converged to the use of search(), on a placeholder
> > regex-pattern. This way neither @/ nor the search history are messed
> > up by irrelevant patterns.
> 
> I have been playing around with the search() but I couldn't quite get
> the hang of it. 
> Could you maybe give me an example on how to use it in relation to an
> abbrev. What I tried was:
> :iabbrev for( for
> (!cursor!;<+++>;<+++>){\n<+++>\n}<C-R>=search('!cursor!',b)<cr>c/+>/e<cr>
> 
> but this inserts the linenumber where it finds the placeholder. 
> I would rather like it ro remove the placeholder and move the cursor
> there. 
> any ideas? 

     That is because search() returns a value.  It is a little odd that
you mix markers, using both !cursor! and <++>, but I guess that makes it
easier to jump back to the first one.  This is a little closer to what
you want:

:iabbrev for( for(!cursor!;<+++>;<+++>){\n<+++>\n}<Esc>:call 
search('!cursor!','b')<cr>cf!

Instead of using <C-R>= , I go into Command-Line mode with <Esc>: .  I
added quotes around the 'b' flag for search() and I used  f!  (in Normal
mode) rather than /+>/e because (1) it goes to the end of the first
marker, not the second and (2) it does not affect the search history.
(It does affect the , and ; commands, though.)

HTH                                     --Benji Fisher

Reply via email to