Tip #297: Start in insert mode without loosing your escape key
tip karma |
Rating 2/5, Viewed by 1219
|
created: |
|
August 3, 2002 17:05 |
|
complexity: |
|
basic |
author: |
|
atkinss AT onid orst edu |
|
as of Vim: |
|
5.7 |
There are two parts to this, each is fairly simple.
First, I want to start in insert mode. Well "set im!" in my vimrc did the job, but I lost the escape key.
Second, I have found that often times, when I'm in command mode, I hit escape trying to get back into insert mode. I am always rewarded with a beep, telling me once again I made that mistake.
So I mapped esc in command mode to set insert mode (":set im") and I mapped esc in insert mode to unset insert mode (<c-o>:set im) Well then I realized if you hit "i" in command mode, escape woulding work the first time. So here's the code to add to your vimrc:
set im! " start in insert mode
map <esc> :set im!<cr> " escape in command mode goes to insert mode
map i :set im!<cr> " i in command mode goes to insert mode
map! <esc> <c-o>:set im!<cr> " escape in insert mode goes to command mode
see :help insert
<<Attach the currently open file to email |
Changing case with regular expressions >>
Additional Notes
|