Wikia

Vim Tips Wiki

Execute accidentally inserted commands

Talk0
1,610pages on
this wiki
Revision as of 09:06, September 29, 2008 by JohnBot (Talk | contribs)

Tip 637 Printable Monobook Previous Next

created January 17, 2004 · complexity basic · author Jochen Behrens · version 5.7


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

inoremap <somekey> <Esc>u@.

This mapping switches to normal mode, undoes 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.

Comments

I guess you meant:

inoremap <somekey> <Esc>u:@.

I prefer

inoremap <somekey> <Esc>u@. i

Also

yy@"

Explanation:

yy yank current line into default register
@" execute default recording

Advertisement | Your ad here

Around Wikia's network

Random Wiki