Vim Tips Wiki

Talk:Recover from accidental Ctrl-U

Back to page

1,624pages on
this wiki
Add New Page

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

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

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)

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Also on Fandom

Random Wiki