Vim Tips Wiki
Register
Advertisement
Tip 1646 Printable Monobook Previous Next

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[]

inoremap II <Esc>I
inoremap AA <Esc>A
inoremap OO <Esc>O

Those mappings stay in insert mode.

  • II go to just before the first non-blank text of the line
  • AA go to the end of the line
  • OO start editing on a new line above the current line

Line modifications[]

inoremap CC <Esc>C
inoremap SS <Esc>S
inoremap DD <Esc>dd
inoremap UU <Esc>u
  • CC change what is on the right of the cursor
  • SS change the whole line
  • DD delete the current line (end in normal mode)
  • UU undo

Comments[]

Advertisement