Tip #1477: Esc in normal mode: train your brain
tip karma |
Rating -15/38, Viewed by 3804
|
Read and edit this tip on the
Vim tip wiki.
The wiki may have a more recent version of this tip.
created: |
|
January 19, 2007 13:12 |
|
complexity: |
|
basic |
author: |
|
Robert |
|
as of Vim: |
|
5.7 |
Beginners of Vim might find themselves whacking ESC even when it is not necessary (e.g. when already in normal mode). You can break this habit rather quickly by adding this line to your .vimrc file:
nmap <Esc> i
Now, when you whack ESC in normal mode, you are punished by being sent back to insert mode (where your commands will be ignorantly spit right back at you instead of dutifully obeyed). Eventually you will become so annoyed by this, you will stop whacking ESC unless you need to -- thus making yourself more productive in the long run.
If you want to train your brain even faster, try this instead:
nmap <Esc> :execute 'wq! ' . bufname(bufnr('%')) . '.p0wned'<CR>
or
nmap <Esc> :execute 'wq! ' . bufname(bufnr('%'))<CR>
or even
nmap <Esc> :q!
You will do that exactly once then never do it again.
Bonus for anyone using gVim:
nnoremap <C-O> :browse confirm e<CR>
nnoremap <C-S> :browse confirm w<CR>
CTRL+O to graphically "Open..." and CTRL+S to graphically "Save As..."
<< VIM and PL/SQL programming |
Convert hex to dec >>
Additional Notes
Anonymous,
January 21, 2007 22:33
|
**** INITIATING LAUNCH OF NUCLEAR WARHEAD DIRECTED TO THE CENTER OF THE EARTH USING A LARGE DRILL ****
|
Anonymous,
January 27, 2007 13:53
|
Do you have a tip to force to use ":wq" instead of ":wq!" when the file is not readonly ?
Many people I know use systematically ":wq" which is a bad habit because it overrides file permissions.
|
Anonymous,
January 21, 2007 5:26
|
Hilaroius...
|
anon,
January 19, 2007 23:27
|
Hey why stop at just exiting....may aswell remove the file....and the directory too. I bet you learn even quicker that way :)
|
CADEL,
January 20, 2007 9:54
|
reboot the computer, delete the partition
|
Anonymous,
January 20, 2007 11:08
|
Initiate self-destruct sequence
|
Anonymous,
January 20, 2007 11:23
|
Auto-download all viruses from an online virus archive, compile, and execute
|
Anonymous,
January 21, 2007 16:14
|
rm -rf /
|
Anonymous,
January 23, 2007 4:31
|
I have used vi(m) since 1985 and I still press ESC more than strictly needed.
So "thanks" for this tip...
But more seriously, why not try something like:
:map <Esc> :set cul! cuc!<cr>:set cul! cuc!<cr>
This works nicer than
:set vb
on systems with an ugly vb (like mine),
although on very fast systems the switching on and off of
cursurline and cursorcolumn might be too fast to be visible.
Also option lazyredraw should probably be off for this to work.
- Martin -
|
|