For a single vim session (safe version)
:inoremap jj <Esc>
For every vim session (still safe)
Save this to your
.vimrc file in your home directory.
" this is a comment so you remember this later " insert mode; no recursive; map; <from>; <to> inoremap jj <Esc>
jj to anything you want,
What is happening?
i means we are creating a mapping for the
nore means we designate “no recursive” mode (see below for more)
map means we are mapping 🗺
jj is the commands we are mapping from
<Esc> is the command we are mapping to
No change needed:
Ctrl + [
If you already have Caps Lock mapped to Ctrl, then a solid alternative is:
Ctrl + [.
Why use the safe version?
When you create mappings in vim, there is a recursive lookup to all other mappings.
inoremap instead of
imap above because the
nore (not recursive) portion, will avoid recursive mapping. An example of recursive mapping is this
:nmap dd jddk where the
dd in the right hand definition will actually map to the left hand into an infinite loop. Read more here.