Can I use SPACE as mapleader in VIM?

VimConfigurationMappingKeyboard ShortcutsCustomization

Vim Problem Overview


From http://items.sjbach.com/319/configuring-vim-right I got that you were supposed to be able to use Space as the mapleader in vim. I've tried but it does not seem to work. Anyone who have made it work?

Tried:

let mapleader = <space>

Vim Solutions


Solution 1 - Vim

Try the following instead:

let mapleader=" "

And remember to write the following line before that, to make sure spacebar doesn't have any mapping beforehand:

nnoremap <SPACE> <Nop>

Solution 2 - Vim

Mapleader is a Vim string variable. To use space as leader, you must escape the special character.

let mapleader="\<Space>"

For more info see,

http://vimdoc.sourceforge.net/htmldoc/eval.html#expr-quote

EDIT:

This no longer works for me in my version of Vim. Even with the suggestion in the comments of unmapping the spacebar in normal mode by running nnoremap <SPACE> <Nop>.

I ending up going with the solution given in the answer below.

map <Space> <Leader>

Solution 3 - Vim

The above solutions are great, however, nothing shows up in the bottom right command corner. If you don't have any use for the \ key anyway, try using map <SPACE> <leader> and \ will show up in the command corner. That and you don't have to unmap space first, as suggested in the commends above.

Solution 4 - Vim

nnoremap > >
nnoremap > > /

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
QuestionMarlunView Question on Stackoverflow
Solution 1 - VimZsolt BotykaiView Answer on Stackoverflow
Solution 2 - VimjayWHYView Answer on Stackoverflow
Solution 3 - VimthosehipposView Answer on Stackoverflow
Solution 4 - VimEric MacFarlandView Answer on Stackoverflow