What is the difference between ‘mapleader’ and ‘g:mapleader’ in Vim?
global-variables, vim
Solution
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`.
Problem
I don’t understand the difference between `let mapleader=","` and `let g:mapleader=","`. I know that `g:` means that it’s a global variable, but I don’t clearly understand the difference. Which one should I use in my `.vimrc` file?