Friday, March 29, 2013

Re: how to undo a register insertion using i_CTRL-R?

On Friday, March 29, 2013 10:55:09 AM UTC-5, Maciej Kalisiak wrote:
> I love the ability of inserting a register content, directly in insert mode, using i_CTRL-R. However, this gets me into trouble from time to time.
>
> For example, I might be on a roll, and without leaving insert mode, I enter a whole paragraph or three, which I want to finish with a contents of a register, which I insert using i_CRTL-R. Except, it turns out I did not get the right register (e.g., there was an intervening cut, so it's no longer "1 but rather "2 or "3). Instead of the expected word or phrase, I accidentally pasted a register which contained massive amount of text. Great, I'll just hit undo key in normal mode to undo it. But hold on! This also undoes the whole paragraph or three I typed in before the mistake.
>
> Gah, how do I undo just the register insertion?! Or do I have to train myself to leave insert mode before register pastes?

This problem, and it's prevention, is closely related to:

http://vim.wikia.com/wiki/Recover_from_accidental_Ctrl-U

To sum up, you should set up a mapping to break the current undo sequence before triggering the CTRL-R, like:

inoremap <C-R> <C-G>u<C-R>

--
--
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/groups/opt_out.

No comments: