that allows you to do a " quick and dirty insert" and get out into normal mode (rss 2.0)" href="https://www.vim8.org/tips/rss2.php?tip_id=289"/>
    sponsor Vim development Vim logo Vim Book Ad

basic 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!

 rate this tip  Life Changing Helpful Unfulfilling 

<<A keymapping to generate Java setters and getters automatically | Text Processing With Integrated Spell Checking >>

Additional Notes

Anonymous, July 26, 2002 8:22
Also check out vimtip #270.
Anonymous, July 26, 2002 9:45
Ctrl+[ is a builtin equivalent to Esc in insert mode...
antoine.mechelynck at belgacom.net, July 26, 2002 12:07
Ctrl-[ is equivalent to <Esc> indeed; but if you use <S-Space>, beware of using the space bar as "independent of shift" as on a typewriter!
jmcpherson at softhome.net, July 29, 2002 12:50
Not a bad idea... and more egronomic (although also less universally available) than the ^[ idea in vimtip #285.

Incidentally, are you the same Jeffery Lim that wrote Impulse Tracker?
jf_____ at fastmail.fm, July 29, 2002 23:32
erm, nope. Different. For one thing, the "Jeffery" is spelt differently. Thanks for the compliments for the tip though.
alex_nanou at yahoo.com, August 14, 2002 16:32
here is another one in relation to the subject: vimtip #314
Thanks...
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to [email protected] after searching the archive. Help Bram help Uganda.
Sponsored by Web Concept Group Inc. SourceForge Logo