Choose a keypress other than the colon ':' to switch to command line mode in vi
You can use nmap
for example
:nmap ; :
to compare the semicolon in the colon . "N" in nmap
indicates normal mode.
If you want to use a function key <F2>
, for example, to enter command line mode from insert mode, you can do:
:imap <F2> <Esc>:
Here is a comprehensive 3 part tutorial on key mappings in vim here .
source to share
To go to rphv's answer , you can swap functionality :
for a different key using nnoremap
. For example, if you want to use ;
instead :
to enter command line mode, you can do this:
nnoremap ; :
nnoremap : ;
This has the advantage that you do not lose functionality ;
. If you tried to do the same with nmap
, like this:
nmap ; :
nmap : ;
none of them will work because of the recursive definition.
source to share