Because I'm still learning vim, I quite often find myself mistakenly entering the wrong command (for example, let's say I entered ci{
, when I meant ca{
). When I do this, vi enters insert mode and (in this case) deletes some text, ready for me to enter a replacement. If I hit Esc
at this point, I go back to normal mode, but the text that the c
command deleted remains deleted. Is there a way for me to go back to normal mode whilst undoing the full effects of that command? (I'm aware I can hit u
after Esc
, but I'm looking for one key/accelerated key).
Add a comment
|
1 Answer
create the binding yourself.
imap <C-u> <esc>u
This would make the key press of control-u go back to regular mode and issue the undo command.
-
Thanks for the tip. I was hoping for a built-in command, but maybe this is what I'll have to do. Sep 14, 2012 at 17:22
-
The ability to define your own mappings is the strength. Trying to build in every user's desires would never work. So vim let's you put in whatever desires you want.– EBGreenSep 14, 2012 at 17:29