Key Mapping
- You can assign a set of commands to a single key or key sequence.
- This is done using the :map and friends commands:
:map Normal, Visual and Operator-pending :vmap Visual :nmap Normal :omap Operator-pending :map! Insert and Command-line :imap Insert :cmap Command-line
- For example, to assign <F2> as copy everything to the clipboard do:
:map <F2> gg"+yG
- Another example, taken from the Vim User Manual is:
:map <F2> GoDate: <Esc>:read !date<CR>kJ
- This one goes to the end of the file (G) inserts "Date:" there (oDate:), inserts the contents of the date command and join the lines together. (kJ)