On 2 Apr, 04:17, Tony Mechelynck <[email protected]> wrote:
> On 01/04/09 19:31, Spiros Bousbouras wrote:
>
> > On 1 Apr, 17:15, Tim Chase<[email protected]>  wrote:
> >> Spiros Bousbouras wrote:
> >>> function! Add_line()
> >>>      call append(0 , "This is a new line")
> >>> endfunction
> >>> imap<F1>  <ESC>:call Add_line()<CR>
>
> >>> The above script gets executed and now I am in Insert mode. I
> >>> type a few characters and then press<F1>. As expected "This is
> >>> a new line" is added at the top of the buffer. Now if I press 'u'
> >>> it removes the new line *and* the characters I had typed right
> >>> before I pressed<F1>. Is there a way to modify the function
> >>> (preferably) or the mapping so that when I press<F1>  a new undo
> >>> block is created so that when I press 'u' only the modification
> >>> by Add_line() gets undone and not what came before I pressed
> >>> <F1>  ?
>
> >> You should be able to insert an undo-break, curtly described at
>
> >>     :help i_CTRL-G_u
>
> > Not only curtly described but also it doesn't appear in the "undo"
> > part of the documentation where I was looking for an answer to
> > my problem.
>
> Yes, quite easy to miss. I search for it a few hours ago and didn't find
> it. I guess the reason for that is that it's a rather late addition. In
> Vim 6 we would have used other means.
>
> Note that |i_CTRL-O| also breaks undo, so
>
>         imap <F1> <C-O>:call Add_line()<CR>
>
> would be good enough (and Vim 6 compatible).

No , this doesn't work.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to