Quick command in insert mode
Talk0this wiki
created February 27, 2010 · complexity basic · author Bmx007 · version 7.0
You can use CTRL-O or CTRL-\ CTRL-O (see :help ins-special-special) to execute a normal-mode command without leaving insert mode. But this is awkward for frequently used commands. Even mapping keys like <F5> or CTRL key combinations can be difficult to reach, and there are not many available keys to map. If you want quick access to common normal-mode commands from insert mode, hitting <ESC> to actually go to normal mode may not be attractive.
You can Avoid the escape key, but it can be faster to map double uppercase letters in insert mode to common commands. Most people don't use two uppercase letters in a row. If you do actually need to insert any text from these mappings, you can always type CTRL-V before the second character in the mapping (:help i_CTRL-V), or wait for the mapping to time out first.
Quick movements
Edit
inoremap II <Esc>I inoremap AA <Esc>A inoremap OO <Esc>O
Those mappings stay in insert mode.
IIgo to just before the first non-blank text of the lineAAgo to the end of the lineOOstart editing on a new line above the current line
Line modifications
Edit
inoremap CC <Esc>C inoremap SS <Esc>S inoremap DD <Esc>dd inoremap UU <Esc>u
CCchange what is on the right of the cursorSSchange the whole lineDDdelete the current line (end in normal mode)UUundo