When using Vim you can find your
:help <Leader) by checking the value of
however there are some edge cases.
mapleader is not defined, you’ll get the message
E121: Undefined variable: mapleader
in which case your Leader is the default value, which is a backslash (
Space bar as Leader
mapleader is set to your space bar (currently this is my preferred Leader value), you won’t see any output.
Tab as Leader
mapleader is set to the tab key, you won’t see any output.
A Better Way to Find Your Leader
The following command will output:
- if leader is undefined, it will display
mapleader is \ (the default value)
- if leader is space bar, it will display
mapleader is <Space>
- if leader is tab, it will display
mapleader is <Tab>
- otherwise, it will display the value of mapleader, e.g.
mapleader is ,
Command to Display Leader
:echo join([ 'mapleader is ', ! exists("mapleader") ? '\' : mapleader ==? "\<Space>" ? '<Space>' : mapleader ==? "\<Tab>" ? '<Tab>' : mapleader, ! exists("mapleader") ? ' (the default value)' : '' ], '')
Breakdown of Command
First we call
echo join(), this outputs all of the strings in the array we pass to
join() concatenated together. We pass a second parameter to
'' so there are no spaces between the parts of the string (the default value for this second parameter is
' '). (See
Then we pass a chain of inline conditionals (see
:help <>), the logic here is
:if ! exists("mapleader") : echo '\' :elseif mapleader ==? "\<Space>" : echo '<Space>' :elseif mapleader ==? "\<Tab>" : echo '<Tab>' :else : echo mapleader :endif
Finally, we display the text ” (the default value)” for the case when mapleader is not defined.
:if ! exists("mapleader") : echo "( the default value)" :endif