Loading ...
Sorry, an error occurred while loading the content.

Re: Breaking undo in Insert mode

Expand Messages
  • Thiago Alves
    Hi guys, I m the author of AutoClose and since almost a year ago I gave up trying to fix all sort of problems caused by inventive solutions to workaround the
    Message 1 of 18 , Jul 12, 2013
    • 0 Attachment
      Hi guys, I'm the author of AutoClose and since almost a year ago I gave up trying to fix all sort of problems caused by inventive solutions to "workaround" the undo break.
      I really like Bram's idea where <C-R>= would not break the undo. If we have that auto complete plugins would be way more simple to implement.

      Is anyone working on this patch at this point?

      On Tuesday, July 9, 2013 8:13:22 AM UTC-7, Bram Moolenaar wrote:
      > Ben Fritz wrote:
      >
      >
      >
      > > On Tue, Jul 9, 2013 at 5:54 AM, Bram Moolenaar <Bram@...> wrote:
      >
      > > >
      >
      > > > That can be done by returning cursor key sequences. No need for
      >
      > > > setline():
      >
      > > >
      >
      > > > imap ( <C-R>=LeftParen()<CR>
      >
      > > > fun! LeftParen()
      >
      > > > return "()\<Left>"
      >
      > > > endfun
      >
      > > > imap ) <C-R>=RightParen()<CR>
      >
      > > > fun! RightParen()
      >
      > > > return "\<Right>"
      >
      > > > endfun
      >
      > > >
      >
      > >
      >
      > > I don't remember how setline() solves the problem, but just returning
      >
      > > cursor sequences doesn't work, because it breaks undo/redo/repeat.
      >
      >
      >
      > Yeah, that's true. I suppose we could avoid saving for undo under
      >
      > certain conditions, but it's quite hard to decide what those conditions
      >
      > are. Perhaps "when inserting a register and the cursor remains within
      >
      > the inserted text"?
      >
      >
      >
      > > If I insert abc(123) with mappings like, then press '.' somewhere
      >
      > > else, I will only get the 123 inserted. Pressing 'u' after inserting
      >
      > > "abc(123) + 456" will only undo the " + 456".
      >
      > >
      >
      > > The mappings that used to work to get around this are complicated;
      >
      > > hence the reason I'm using a plugin instead of simple mappings; but
      >
      > > previously somehow using setline() allowed all of undo, redo, and
      >
      > > repeat to work as if there were not any mappings. Now only repeat
      >
      > > works.
      >
      >
      >
      > --
      >
      > "I love deadlines. I especially like the whooshing sound they
      >
      > make as they go flying by."
      >
      > -- Douglas Adams
      >
      >
      >
      > /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
      >
      > /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
      >
      > \\\ an exciting new programming language -- http://www.Zimbu.org ///
      >
      > \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

      --
      --
      You received this message from the "vim_dev" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      ---
      You received this message because you are subscribed to the Google Groups "vim_dev" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    Your message has been successfully submitted and would be delivered to recipients shortly.