Raimondi / delimitMate

Vim plugin, provides insert mode auto-completion for quotes, parens, brackets, etc.
http://www.vim.org/scripts/script.php?script_id=2754
1.98k stars 117 forks source link

atomic undo #171

Closed justinmk closed 10 years ago

justinmk commented 10 years ago

I believe undo has been discussed before, at least in the auto-pairs issues and also on the mailing list (can't find the thread, alas). Using arrow keys in insert mode breaks up undo, so in both delimitmate and autopairs, inserting (foo requires two u commands to undo the entire text. Obviously this isn't desirable as the user didn't explicitly exit insert mode, and expects the inserted text to be atomic. This also affects repeat.

I've found a way to "fix" undo/redo for delimitmate, and probably autopairs too:

inoremap ( <C-r>='()'<cr><esc>:undojoin<cr>i

Since <esc> moves the cursor to the left, the arrow keys are never touched. (AFAICT, arrow keys break :undojoin, and based on the vim_use thread, this is by design.)

Repeat . still doesn't work with this approach, but that could be solved easily with tpope's repeat.vim.

Any interest in applying this technique to delimitmate?

I've only tested on Vim 7.4.155 but this should work with previous versions.

justinmk commented 10 years ago

closing since i found https://github.com/Raimondi/delimitMate/issues/138