Friday, January 16, 2015

Re: Any automatic bracket-insertion plugins not breaking undo?

Christian Brabandt wrote:

> On Fr, 16 Jan 2015, Ben Fritz wrote:
>
> > The problem is, there is no way to move the cursor in insert mode,
> > without breaking the undo sequence. Such a capability would allow both
> > of these mappings:
> >
> > inore ( ()<Left> inore <expr> ) GetNextChar()==")" ? "\<Right>" : ")"
> >
> > Alternatively, there is no way in insert mode to insert a character
> > after the cursor, or delete the character after the cursor. Such a
> > capability would allow:
> >
> > inore <expr> ( ")".PutCharAfter(")") inore <expr> ) GetNextChar()==")"
> > ? DeleteNextChar().")" : ")"
> >
> > At one point, there was a workaround that exploited a bug in setline()
> > that allowed the undo/redo to work. You could use setline() to change
> > the line without breaking undo sequence. I don't remember how repeat
> > worked, but I think it involved an <Esc> mapping.
> >
> > If either the abilities above (moving the cursor without breaking
> > undo, or insert/delete after the cursor) were implemented as Vim
> > insert-mode commands, I would consider dropping the use of a plugin
> > and just writing my own mappings.
> >
> > As it is, I tried the pull request I mentioned on delimitMate, and it
> > seems to work for simple cases, but either visual-block mode messes it
> > up. I have an unsatisfactory workaround I posted as a comment on that
> > pull request that I'm using for the present.
>
> Hm, we already have special cases <C-[Left|Right]> and <S-[Left|Right]>
> to move by word|WORD. So how about making <M-Left> and <M-Right> move
> without breaking undo?
> https://github.com/chrisbra/vim-mq-patches/blob/master/move_cursor_without_breaking_undo

It's very likely there will be a request for other movements, e.g. a
word back. How about a prefix for movement commands? Something
starting with CTRL-G. It's several keys to type, but I assume this will
mostly be used in mappings.


--
From "know your smileys":
=):-) Uncle Sam

/// Bram Moolenaar -- Bram@Moolenaar.net -- 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_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment