0

I want to change the shortcut for entering command-line mode in vim from : to ;.

I can do:

:map ; :

and that works, but now I want to remap : to other command. If I do that ; is changed too and I cannot enter command line mode any more.

I suppose I should use something like:

:map : <command-line-mode>

but I don't know the correct command to use.

nadapez
  • 2,603
  • 2
  • 20
  • 26
  • 1
    Do you know the difference between `:map` and `:noremap`? http://vimdoc.sourceforge.net/htmldoc/map.html#:noremap – phd Aug 27 '22 at 20:58
  • Use not recursive mapping `noremap` instead. See [What is the difference between the remap, noremap, nnoremap and vnoremap mapping commands in Vim?](https://stackoverflow.com/questions/3776117/what-is-the-difference-between-the-remap-noremap-nnoremap-and-vnoremap-mapping) – Johan Chane Sep 03 '22 at 13:17

1 Answers1

1
:noremap ; :
:noremap : <something else>

Using map only will map the key recursively, meaning if you map ; to :, then : to someting else, now both ; and : will do whatever you mapped : to do. Because ; is mapped to do whatever : does. to prevent this recursive behavior, use non-recursive maps noremap, which will map each key independently of what the mapped-to key does.

Maaddy
  • 618
  • 5
  • 13