What is the difference between ‘mapleader’ and ‘g:mapleader’ in Vim?
If the aforementioned statements are both located outside of function
definitions, they have the identical effect of setting a global variable. However, if the first statement, without the g:
prefix, is used in
a function body, it defines a variable local to that function.
See :help internal-variables
and especially :helpg In a function:
.
Hence, outside function definitions one can access the global map-leader
variable simply as mapleader
.
let mapleader=","
as stated in the doc.
Why would you want to use g:mapleader
? g:
is mostly used in plugins to let
global variables in order to expose settings to other plugins or for you to play with in your .vimrc.