Tip: #1117 - Use tab instead of escape
Created: January 30, 2006 8:28 Complexity: basic Author: Matt Zyzik Version: 5.7 Karma: 45/30 Imported from: Tip#1117
People get tired of hitting Escape all the time to get into normal mode. Others have given advice of using Control-[ or mapping CapsLock to Escape.
I now give the advice to use Tab for getting to normal mode.
Tab is by far faster than Escape or Control-[; and there is no burden of configuring every machine you go on to map CapsLock to Escape.
Now that you've read my advice and decided to start using Tab for Escape, the thought arises, "how will I insert tabs?".
You can always shift lines using << and >> when in normal mode. When in insert mode, you can use Control-T and Control-D to do what >> and << do, respectively. I personally like to map Alt-i to insert a Tab, because it's the fastest key combination.
Enough talk; here's the setup:
inoremap <m-i> <tab>
nnoremap <tab> <esc>
vnoremap <tab> <esc>gV
onoremap <tab> <esc>
inoremap <tab> <esc>`^
Notes: the gV makes sure to deselect the selection; and the `^ puts the cursor back to where it was last in insert mode (so there is no going back a char when escaping to normal mode).
Comments
The only true way to map:
imap jj <Esc>
Anonymous
, January 30, 2006 12:11
Well, I think that using <Tab> instead of <Esc> must be only (!) optional. And it must NOT be a recommended way of usual using Vim.
<Esc> is a traditional (Sic!) way to switch Vim's (and Vi's) modes, and it is so logically clear for users that any changes are not so good as real thing.
Can you imagine that some people will ask to change something, i.e. GUI modes of Vim with implementing some new features like tabs or something else? And we all would say then that something wrong has been happend with compatibility and usability of Vin, espesially in terminal work.
Such changes potentially may totally kill Vim because they deeply change it's main ideas and ideology as it is.
This is on my own mind, of course.
Sincerelly, Roman Andriyashik
romchyk--AT--yandex.ru , February 3, 2006 20:59