Saturday, January 17, 2015

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

Ben Fritz wrote:

> ------=_Part_1625_1020240385.1421465043545
> Content-Type: text/plain; charset=UTF-8
>
> On Friday, January 16, 2015 at 4:55:44 PM UTC-6, Christian Brabandt wrote:
> > Hi Bram!
> >
> > On Fr, 16 Jan 2015, Bram Moolenaar wrote:
> >
> > >
> > > Christian Brabandt wrote:
> > > > 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.
> >
> > I thought about that. But my fear is, that this will allow to jump
> > anywhere in insert mode and I think this would probably break undo (a
> > problem we have just fixed with <c-r>= in insert mode before 7.4).
> > So I did intentionally just allow <M-Left> and <M-Right> in the hope,
> > that this will still allow proper undo and will cover most of the snip
> > plugin use-cases.
> >
>
> I'm definitely going to try the patch, but I think I'd prefer a
> different prefix also. If it works this is exactly what is needed for
> auto-close, without all the fuss of a big plugin (unless you want
> that...)
>
> The meta-keys have traditionally been "safe" for mapping in Vim
> without stepping on existing features, I think keeping it that way is
> a good idea.
>
> And I agree these will mostly be used in mappings.
>
> CTRL-G_u breaks undo sequence. What about CTRL-G_U keeping undo
> sequence unbroken?
>
> It's ok for the short term if just CTRL-G_U_<Left> and
> CTRL-G_U_<Right> are supported to start with...with potential for more
> if there is a need for them.
>
> I'd probably restrict to movement within a single line, though.

Since undo works by saving the line before changing it, restricting the
"keep undo" modifier to only work when the cursor remains in the same
line should work. It's also fairly easy to understand, instead of
making a list of specific commands for which undo can be kept.

Note that "." to repeat the insert may not always work properly. Need
to check that.

--
From "know your smileys":
(X0||) Double hamburger with lettuce and tomato

/// 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: