map

Rate this post
 *map.txt* For Vim version 5.4. Last change: 1999 Jul 20 VIM REFERENCE MANUAL by Bram Moolenaar Key mapping and abbreviations. 1. Key mapping |key-mapping|
2. Abbreviations |abbreviations|
3. User-defined commands        |user-commands| ============================================================================== 1. Key mapping *key-mapping* There are commands to enter new mappings, remove mappings and list mappings.
See |map-overview| for the various forms of "map" and their relationships with
modes. :map {lhs} {rhs} *:map* :nm[ap] {lhs} {rhs} *:nm* *:nmap* :vm[ap] {lhs} {rhs} *:vm* *:vmap* :om[ap] {lhs} {rhs} *:om* *:omap* :map! {lhs} {rhs} *:map!* :im[ap] {lhs} {rhs} *:im* *:imap* :cm[ap] {lhs} {rhs} *:cm* *:cmap* Map the key sequence {lhs} to {rhs} for the modes where the map command applies. The result, including {rhs}, is then further scanned for mappings. This allows for nested and recursive use of mappings. :no[remap] {lhs} {rhs} *:no* *:noremap* :nn[oremap] {lhs} {rhs} *:nn* *:nnoremap* :vn[oremap] {lhs} {rhs} *:vn* *:vnoremap* :ono[remap] {lhs} {rhs} *:ono* *:onoremap* :no[remap]! {lhs} {rhs} *:no!* *:noremap!* :ino[remap] {lhs} {rhs} *:ino* *:inoremap* :cno[remap] {lhs} {rhs} *:cno* *:cnoremap* Map the key sequence {lhs} to {rhs} for the modes where the map command applies. Disallow mapping of {rhs}, to avoid nested and recursive mappings. Often used to redefine a command. {not in Vi} :unm[ap] {lhs} *:unm* *:unmap* :nun[map] {lhs} *:nun* *:nunmap* :vu[nmap] {lhs} *:vu* *:vunmap* :ou[nmap] {lhs} *:ou* *:ounmap* :unm[ap]! {lhs} *:unm!* *:unmap!* :iu[nmap] {lhs} *:iu* *:iunmap* :cu[nmap] {lhs} *:cu* *:cunmap* Remove the mapping of {lhs} for the modes where the map command applies. The mapping may remain defined for other modes where it applies. Note: Trailing spaces are included in the {lhs}. This unmap does NOT work:
 :map @@ foo
 :unmap @@ | print :mapc[lear] *:mapc* *:mapclear* :nmapc[lear] *:nmapc* *:nmapclear* :vmapc[lear] *:vmapc* *:vmapclear* :omapc[lear] *:omapc* *:omapclear* :mapc[lear]! *:mapc!* *:mapclear!* :imapc[lear] *:imapc* *:imapclear* :cmapc[lear] *:cmapc* *:cmapclear* Remove ALL mappings for the modes where the map command applies. {not in Vi} Warning: This also removes the default mappings. :map
:nm[ap]
:vm[ap]
:om[ap]
:map!
:im[ap]
:cm[ap] List all key mappings for the modes where the map command applies. Note that ":map" and ":map!" are used most often, because they include the other modes. :map {lhs} *:map_l* :nm[ap] {lhs} *:nmap_l* :vm[ap] {lhs} *:vmap_l* :om[ap] {lhs} *:omap_l* :map! {lhs} *:map_l!* :im[ap] {lhs} *:imap_l* :cm[ap] {lhs} *:cmap_l* List the key mappings for the key sequences starting with {lhs} in the modes where the map command applies. {not in Vi} These commands are used to map a key or key sequence to a string of
characters. You can use this to put command sequences under function keys,
translate one key into another, etc. See |:mkexrc| for how to save and
restore the current mappings. There are five sets of mappings
- For Normal mode: When typing commands.
- For Visual mode: When typing commands while the Visual area is highlighted.
- For Operator-pending mode: When an operator is pending (after "d", "y", "c", etc.).
- For Insert mode. These are also used in Replace mode.
- For Command-line mode: When entering a ":" or "/" command. *map-overview* *map-modes*
Overview of which map command works in which mode:  commands: modes: 
 Normal Visual Operator-pending 
:map :noremap :unmap :mapclear X X X
:nmap :nnoremap :nunmap :nmapclear X . .
:vmap :vnoremap :vunmap :vmapclear . X .
:omap :onoremap :ounmap :omapclear . . X  Insert Command-line 
:map! :noremap! :unmap! :mapclear! X X
:imap :inoremap :iunmap :imapclear X .
:cmap :cnoremap :cunmap :cmapclear . X The original Vi did not have separate mappings for
Normal/Visual/Operator-pending mode and for Insert/Command-line mode.
Therefore the ":map" and ":map!" commands enter and display mappings for
several modes. In Vim you can use the ":nmap", ":vmap", ":omap", ":cmap" and
":imap" commands to enter mappings for each mode separately. To enter a mapping for Normal and Visual mode, but not Operator-pending mode,
first define it for all three modes, then unmap it for Operator-pending mode: :map xx something-difficult :ounmap xx
Likewise for a mapping for Visual and Operator-pending mode or Normal and
Operator-pending mode. *map-listing*
When listing mappings the characters in the first two columns are:     CHAR MODE         Normal, Visual and Operator-pending n Normal v Visual o Operator-pending ! Insert and Command-line i Insert c Command-line A "*" just before the {rhs} indicates that it is not remappable. Everything from the first non-blank after {lhs} up to the end of the line
(or '|') is considered to be part of {rhs}. This allows the {rhs} to end
with a space. Note: When using mappings for Visual mode, you can use the "'