The command map localleader are explained very nicely here. How do I read the current value of the <localleader> thingy? Is this a variable or what?

  • 2
    Global variables: echo g:mapleader echo g:maplocalleader (usually you can skip the g:). Hint: you can also set them :D
    – VanLaser
    Jan 28, 2016 at 10:48
  • 2
    @VanLaser, don't be shy; post answers.
    – romainl
    Jan 28, 2016 at 11:01
  • 1
    But, but .. they are SO simple :( I do encourage the author of the question to post the answer himself/herself, in a good quality format.
    – VanLaser
    Jan 28, 2016 at 11:36
  • 1
    I could, but this information is available already.
    – VanLaser
    Jan 28, 2016 at 12:07
  • 2
    No need to apologize :) What I mean is, I don't like writing long answers, unless absolutely necessary.
    – VanLaser
    Jan 28, 2016 at 12:23

1 Answer 1


From :h maplocalleader:

                                        <LocalLeader> maplocalleader
<LocalLeader> is just like <Leader>, except that it uses "maplocalleader"
instead of "mapleader".  <LocalLeader> is to be used for mappings which are
local to a buffer.

Recursing on to :h <Leader> (which is just above this paragraph):

                                        <Leader> mapleader
To define a mapping which uses the "mapleader" variable, the special string
"<Leader>" can be used.  It is replaced with the string value of "mapleader".
If "mapleader" is not set or empty, a backslash is used instead.  Example: 
        :map <Leader>A  oanother line<Esc>
Works like: 
        :map \A  oanother line<Esc>
But after: 
        :let mapleader = ","
It works like: 
        :map ,A  oanother line<Esc>

So, mapleader is a variable, and therefore maplocalleader is too.

The tricky part, of course, is that neither is set by default - and so Vim uses \ as the leader. If you try to examine the value of these two variables, by e.g., let maplocalleader or echo mapleader, Vim will just throw an error:

E121: Undefined variable: mapleader

How do you set it? The <Leader> help quoted above has an example:

let mapleader = ","

Similarly, for example:

let maplocalleader = "_"
  • And, how do you inspect its value?
    – Yossi Gil
    Jan 28, 2016 at 14:14
  • 3
    @YossiGil let maplocalleader or echo maplocalleader, as I have already mentioned.
    – muru
    Jan 28, 2016 at 14:16
  • I edited the answer so that this would be more explicit.
    – Yossi Gil
    Jan 28, 2016 at 17:19
  • 2
    Note that Vim will always expand the current value of mapleader/maplocalleader when it's used, and that re-setting the value to something else will not affect any previous instances of its usage, so getting the current value of mapleader may not reflect the value that Vim actually used to expand the key mappings (see the code example here). Jan 29, 2016 at 2:12

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.