sponsor Vim development Vim logo Vim Book Ad

basic Tip #637: execute accidently inserted commands

 tip karma   Rating 23/8, Viewed by 810 

created:   January 17, 2004 12:44      complexity:   basic
author:   Jochen Behrens      as of Vim:   5.7

If you are in insert mode and typed an command for normal mode, you can use it.

inoremap <somekey> <esc>u@.

This mapping switches to normal mode, undo'es the last insertion and takes it as a command.

Most times I need it, if I typed dd and the line still remains because of Insert-Mode and the unwanted 'dd' ist somewhere
in my text.

 rate this tip  Life Changing Helpful Unfulfilling 

<<Adding Vim to MS-Windows File Explorer Menu | Editing ActiveState Perl batch files >>

Additional Notes

[email protected], January 18, 2004 3:12
I guess you meant:

inoremap <somekey> <esc>u:@.
[email protected], January 19, 2004 13:01
I prefer inoremap <somekey> <esc>u@. i
[email protected], January 20, 2004 1:58
Also
yy@"

yy    yank current line into default register
@"   execute default recording
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to [email protected] after searching the archive. Help Bram help Uganda.
    stats
Sponsored by Web Concept Group Inc. SourceForge.net Logo