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?
1 Answer
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 = "_"
-
-
3@YossiGil
let maplocalleader
orecho maplocalleader
, as I have already mentioned.– muruJan 28, 2016 at 14:16 -
-
2Note 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 ofmapleader
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
echo g:mapleader
echo g:maplocalleader
(usually you can skip theg:
). Hint: you can also set them :D