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

72017Re: Breaking undo in Insert mode

Expand Messages
  • Benjamin Fritz
    Jul 9, 2013
      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.

      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.

      --
      --
      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.
    • Show all 18 messages in this topic