Ben Fritz wrote: > >> On Saturday, April 5, 2014 2:02:23 PM UTC-5, Bram Moolenaar wrote: > >> > > >> > You can record into a register and replay that. > >> > > >> > >> This is not an option for the desired use case, of creating a plugin > >> to automatically insert closing parentheses and the like as you type > >> the opening character. For that we need to be able to move the cursor > >> in insert mode without breaking undo and without knowing in advance > >> that we need to be recording a macro. One cannot start recording a > >> macro with a mapping, 'q' does not function in a mapping according to > >> the help. So the user would manually need to start recording before > >> typing every single time, so mapping every insert-mode entry key would > >> not only be annoying, it wouldn't work. Plus, one would want a plugin > >> such as this to be itself recordable in a macro, which can't be done > >> if you must record a macro to accomplish the task. > > > > I have no clue how you could repeat the changes a plugin makes with ".". > > The plugin could do anything, with any kind of advanced logic. How > > would "." know what to repeat? It can't possibly know that you inserted > > ")" in a specific place and repeat that. > > > > Well at least we could join the undo sequence so u/<C-R> work properly > afterward. Potentially repeat.vim can help here.
Implementing joining undo is possible. But often users ask for breaking up insert into smaller undo-able pieces. That's why we have CTRL-G u. > I know that by abusing setline() in previous versions of Vim, > delimitMate and other plugins managed to get this working. > > But now nobody seems to have found a working hack. > > It would be better to support it intentionally. For example, with an > insert-mode command to chain two changes together. The problem is that there will not be a standard way how to apply those two changes. If it's just two inserts after another it would be possible, but in general the cursor would have moved somewhere else and perhaps indent depends on the indent of another line. Most likely the solution lies in repeating what the plugin does by invoking the plugin again. Instead of trying to record and replay what the plugin ended up doing. So the redo buffer would contain whatever triggered the plugin, and redo would trigger the plugin again. How do these kind of plugins get triggered anyway? Insert mode mapping? Would be good to start with a relevant example. > :undojoin works for arbitrary ex commands. Why can't we have something > similar for insert mode segments? -- hundred-and-one symptoms of being an internet addict: 32. You don't know what sex three of your closest friends are, because they have neutral nicknames and you never bothered to ask. /// Bram Moolenaar -- b...@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_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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.