On Friday, January 16, 2015 at 3:57:37 AM UTC-6, Christian Brabandt wrote: > Am 2015-01-15 15:53, schrieb Ben Fritz: > > On Wednesday, January 14, 2015 at 10:37:15 AM UTC-6, Ben Fritz wrote: > >> A feature I've been missing ever since just before Vim 7.4 came out, > >> is > >> the automatic closing of matched characters. E.g. if I insert abc(def > >> I > >> want to get abc(def|) where '|' denotes my cursor. Then if I type the > >> closing ) I want my cursor to jump over the existing ) rather than > >> inserting a second one. > >> > >> > >> If that's all I wanted, some fairly simple mappings can do the job for > >> me. But, after inserting "abc(def[ghi])", I want to be able to undo > >> that > >> insertion, and redo that insertion, and potentially even REPEAT that > >> insertion, as if I had typed it all out manually in one insert. > > > > Incidentally, at the moment I'd settle for simply not breaking > > undo/redo. If I want to repeat something I normally can prepare that > > in advance by using <C-V> to avoid the mappings. > > That would need a change to the source, right? Did we ever talk about > how to prevent this or what would have to be done, to not break undo? > Is there an easy way to reproduce the issue without having to install > some plugins? >
Pretty much any of the methods at http://vim.wikia.com/wiki/Automatically_append_closing_characters 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. -- -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
