A key sequence can be re-mapped to another key sequence using one of the map variants.
As an example, the following typical map will exit Insert mode when you press jk in quick sequence:
:inoremap jk <Esc>
There are multiple variants of :map for different modes.
| Commands | Modes |
|---|---|
:map, :noremap, :unmap | Normal, Visual and Operator-pending mode |
:map!, :noremap!, :unmap! | Insert and Command-line mode |
:nmap, :nnoremap, :nunmap | Normal mode |
:imap, :inoremap, :iunmap | Insert and Replace mode |
:vmap, :vnoremap, :vunmap | Visual and Select mode |
:xmap, :xnoremap, :xunmap | Visual mode |
:smap, :snoremap, :sunmap | Select mode |
:cmap, :cnoremap, :cunmap | Command-line mode |
:omap, :onoremap, :ounmap | Operator pending mode |
Usually, you should use the :noremap variants; it makes the mapping immune to remapping and recursion.
:map (or one of the variations above).:map <key> where <key> is a sequence of keys<> notation, like <Esc>. For the full list of key codes, see http://vimdoc.sourceforge.net/htmldoc/intro.html#keycodes:nmapclear - Clear all normal mode maps:nunmap - Unmap a normal mode maptimeout and ttimeout variablesimap jk <Esc>: typing jk in insert mode will bring you back to normal modennoremap tt :tabnew<CR>: typing tt in normal mode will open a new tab pagennoremap <C-j> <C-w>j: typing <C-j> in normal mode will make you jump to the window below and to the leftvmap <C-c> \cc: typing <C-c> in visual mode will execute \cc (NERDCommenter command to comment the line). As this relies on a plugin mapping, you cannot use :vnoremap here!futher reading here