Tip #289: Alternative <escape> that allows you to do a "quick and dirty insert" and get out into normal mode
tip karma |
Rating 18/13, Viewed by 1573
|
created: |
|
July 26, 2002 1:43 |
|
complexity: |
|
basic |
author: |
|
Jeffrey Lim |
|
as of Vim: |
|
5.7 |
This is an alternative key combo for the escape key from the one mentioned by David A. Rogers in vimtip #285.
I do a lot of editting in Vim, and I've always found myself in situations where I had to "do a quick insert" - basically (from normal mode), change into insert mode, type in one quick word, then <esc> out, then navigate elsewhere.
As has been rightly observed by a lot of people, the <esc> key can sometimes be a little bit out of the way. But that's no problem for ViM, is it?
At first, I thought of editting the ViM source code itself, in order to come up with a command that could do things like say "let me jump into insert mode, type a few quick words, then escape out into normal mode when i press something like double <space>".
It was only later when reading through the section in Jesse Goerz's "Beginner's Guide to ViM" on remapping (http://newbiedoc.sourceforge.net/tutorials/vim/mapping-vim.html) that I got inspired to retake a look at using remapping as an alternative instead.
This is what I came up with.. Use whatever is comfortable for you - single or double <Shift-space>
:map! <S-space> <esc>
:map! <S-space><S-space> <esc>
With this quick combo ("Shift", + <space>), one can easily (and might I add, intuitively) "do a quick insert" and exit quickly out into normal mode. I guess I always thought the <space> would be a good way to do this sort of thing, since it is after all, so intuitive in the typing process. So why not make it such that it can "escape" you out into normal mode as well? Just type 'i', to go into insert mode, type in your stuff, and once you're done, hit Shift-space!
<<A keymapping to generate Java setters and getters automatically |
Text Processing With Integrated Spell Checking >>
Additional Notes
|