I want my mapleader to be ; and keep his Vim functionality, therefore remap the default ; Vim function to another key, let's say '.

I'm new to Vim and it seems like a simple question but I can't find exactly what I what. If you think it's a bad idea, feel free to criticize.

I've already included this line in my .vimrc:

let mapleader = ";"
  • Read help map to learn about mapping keys. Youll likely want nnoremap here
    – D. Ben Knoble
    Commented Sep 23, 2017 at 23:29

1 Answer 1



Use noremap (nnoremap to make sure make it work only in normal mode)

let mapleader=";"
nnoremap '. ;

Better leader

IMO, you should remap ; to : (if you're on QWERTY). Most people remap their leader to , also. I think you should do the same (I did and I'm very happy with it). Here's how you do it (just adapt it to your needs).

map vs noremap

map allows you to map certain keystrokes to other ones. For example:

map ; :

What this does is as soon as you press ;, it'll do exactly what it would've done if you pressed :.

To restrict this shortcut to work only in normal mode, just use nmap:

nmap ; :

BTW, do you know what it would have done if you used map and pressed ; in insert mode? It would have inserted a :!

The problem with map (and nmap, imap, all the family) is that it uses user defined shortcut. For example

imap a b
imap b c

So, when you press a, it'll in fact "press" b, and then "press" c because of the second imap (in insert mode of cours). So, when you press a, it'll insert a c.

And that's no good at all. It might sounds good, but it isn't reliable, since everything can be remap without you knowing.

So, to counter that, you got noremap (and nnoremap, inoremap, all the family again). These ones only use vim's default keybindings. It doesn't take into account the other mapping. That's the ones you want to use unless you want to use a plugin's shortcut, or one of yours.

So, with the previous example, if we would have used inoremap, and press a, we would've got b.

So, we can now interchange : and ;:

nnoremap ; :
nnoremap : ;

If you use nmap, it'll loop forever (; would press :, which would press ;, which would...)

Visual mode

You'll probably want this remap in visual mode too:

nnoremap : ;
nnoremap ; :
vnoremap ; :
vnoremap : ;

If you want to learn vim, I strongly recommend you read Learn VimScript the hard way.

If you want to see the different options about anything in vim, the help's great. In this case :help map.

Extra tip

:tab help map

Opens the help page in a new tab (gt and gT to navigate tabs)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.