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.

> so you'd do something like
>
>    imap <f1> <c-g>u<esc>:call Add_line()<cr>

This works , thank you. Anyone knows if it's possible to achieve
the same effect from within a script ?

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

Reply via email to