How can I figure out which key is set as my <Leader>, and how do I remap it?

2 Answers 2


By default your <leader> is \, backslash. You can check it with:

:echo mapleader

If this gives you an E121: Undefined variable: mapleader, it means it's set to the default of \. If it gives you something else, then it's that :-)

You can easily remap it. I mapped it to the space-bar:

:let mapleader = "\<Space>"

Note that the value of mapleader is used at the moment the mapping is defined. So this example:

let mapleader = ","
nnoremap <Leader>a :echo "Hey there ,"<CR>

let mapleader = "\<Space>"
nnoremap <Leader>a :echo "Hey there space"<CR>

Will produce two mappings: ,a and <Space>a.

This means that the current value of mapleader is not necessarily the value that was used to define your mappings!

In addition, there's the maplocalleader, which is the same as mapleader, except that it's used by <LocalLeader> and that it's local to the current buffer.

More information about <Leader> can be found in Vim's help with :help mapleader.

  • 7
    Why do we need a backslash in "\<Space>"?
    – thameera
    Commented Feb 4, 2015 at 9:52
  • 16
    The backslash is required because otherwise vim will recognize "<Space>" as a normal string and not the code for the space key. See :help expr-string for examples.
    – tokoyami
    Commented Feb 4, 2015 at 14:38
  • 2
    Just a note: e.g. let mapleader = ' ' also works for setting <Leader> to space. If there are any possible side-effects by using this syntax, feel free to mention them. Commented Feb 20, 2015 at 12:32
  • It appears that maplocalleader is also set to backslash by default. Maybe that's what was meant by "is the same as mapleader, but I wasn't sure at first.
    – Mars
    Commented Jan 5, 2018 at 4:11
  • 2
    How can I undo a let mapleader = "," after the fact? I tried unlet mapleader as well as let mapleader = "\" but it doesn't work. I need this because I am using this bundle github.com/amix/vimrc where it suggests to have my own separate configuration file. The bundle maps leader to the comma so I want to undo this in my separate config file.
    – Michael
    Commented Sep 1, 2019 at 17:48

You can display the current leader key like this :let mapleader

  • 4
    Trying this, I get E121: Undefined variable: mapleader. Commented Feb 4, 2015 at 9:37
  • Then for some reason the mapleader was not set or has been unset
    – craigp
    Commented Feb 4, 2015 at 9:38
  • 5
    Oh, got it. Just a note for others then, if you don't explicitly set the leader key then you get the error above. Commented Feb 4, 2015 at 9:45
  • 4
    if you get E121: Undefined variable: mapleader, that means it was not set, which will use the default, which is a backslash "\"
    – wisbucky
    Commented Jun 26, 2019 at 18:28

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.