Show current <leader> key setting?

Vim

Vim Problem Overview


I'm having a problem with VIM whereby none of my commands work.

Is there a way I can see what my <leader> is currently set to?

Vim Solutions


Solution 1 - Vim

To see the current value currently defined for <leader>, use:

:let mapleader

Producing output like:

> mapleader ,

It may be undefined if not previously set, defaulting instead to a backslash \

Solution 2 - Vim

By default mapleader is not set, and special string "<Leader>" means \.

If you do:

:echo mapleader

you will get

Undefined variable: mapleader
Invalid expression: mapleader

If you want to set special string "<Leader>" to a different key, say ",", which is recommended by many, do:

:let mapleader=","

Then

:echo mapleader
,

Solution 3 - Vim

Fortunately, map expands <key_name> values in both the LHS and RHS. You can exploit this to see the value of <Leader> even if it is the default value.

:nmap temp :echo('your leader is "<Leader>"')<Esc>| execute 'normal temp'| nunmap temp

Note that if you put this in your .vim/vimrc it will pause with "Press ENTER or type command to continue". Please comment if you know how to fix this.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDavid TuiteView Question on Stackoverflow
Solution 1 - VimMichael BerkowskiView Answer on Stackoverflow
Solution 2 - VimXuanView Answer on Stackoverflow
Solution 3 - VimtivnView Answer on Stackoverflow