Hello, * On Mon, Sep 25, 2006 at 08:29:02PM +0200, Kim Schulz <[EMAIL PROTECTED]> wrote: > > 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.
As Benji said, search() returns a value that is not an insert mode action, but a line number. > Could you maybe give me an example on how to use it in relation to an > abbrev. What I tried was: My use of search() is completely encapsulated. It is called from within a function that returns the normal mode action that can reselects the placeholder once out of the function. It is used then in the family of mappings !jump!, !jumpB!, ... Then, my smart-abbreviations (they are context-sensitive) insert a text through <c-r>=InsertSeq(...., \ 'for (!cursorhere! ; !mark! ; !mark!)\n{\n!mark!\n}') InsertSeq() is really tricky. Among the may things it does, it replaces "!stuff!" by the keys binded to the insert mode-mapping "!stuff!" -- 99% of the time the ones I code (and use in InsertSeq()) rely on a function call. !cursorhere! takes a snapshot of cursor position, and InsertSeq() move the cursor to the snapshotted position -- when it detects !cursorhere!. Actually I could have used the placeholder inserted by mark, but I wanted to be able to place the cursor anywhere, not necessarily on the first placeholder. IIRC, that's what has been done in Srinath & al. IMAP.vim plugin: the cursor is moved to the first placeholder. HTH, -- Luc Hermitte http://hermitte.free.fr/vim/