Choose a keypress other than the colon ':' to switch to command line mode in vi

Is there a way to achieve this remapping? I looked a little at

map

      

and

inoremap

      

but they seem to affect in a given mode, not how to enter a given mode.

+3


source to share


2 answers


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 .

+4


source


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.

+4


source







All Articles