Wikia

Vim Tips Wiki

Talk:Recover from accidental Ctrl-U

Back to page

1,614pages on
this wiki

This line is still in vimrc_example.bin, but does not seem to work anymore, at least for VIM 7.4 on Windows.

   inoremap <C-U> <C-G>u<C-U>

Now in insert mode, the first time <C-U> is pressed, nothing happens. If you insert some more text, and then press <C-U> again, the newly added text is removed, and the text you originally typed is still there. If you press <ESC> and u, nothing happens -- the removed text is still lost.


Works fine, for me, in Windows gvim 7.4.629. Starting with gvim -N -u NONE -i NONE, I set up the above mapping, and enter text:

one two three
abc|

The '|' is the cursor. Staying in insert mode, I type <C-U> to get (still in insert mode):

one two three
|

Now I can type "four five six" to get:

one two three
four five six|

I hit <Esc>, then undo a change with u:

one two three
abc

This is exactly what I expect.

If you have a different scenario that demonstrates the issue, then I suggest asking on vim_dev or vim_use mailing list about it.

--Fritzophrenic (talk) 21:40, February 16, 2015 (UTC)

Around Wikia's network

Random Wiki