3

I was trying to remap some keys to switch to the next buffer, but something doesn't work, I have these lines on my .vimrc file:

" Cambia tecla lider a <Space>
let mapleader="<Space>"

" Switch to next buffer
nnoremap <Leader>l :bn<CR>

" Switch to previous buffer
nnoremap <Leader>h :bp<CR>

" Split the window
nnoremap <Leader>k :split<CR>

Are those lines okay? or Is there something wrong?

An observation: when I change <Leader> to <Space> it works.

  • 1
    Try let mapleader = "\<Space>". Note the back slash inside the quote. – zundarz Dec 21 '16 at 0:04
4

Inside :map commands, the special :help key-notation needs to be used, especially for space, because whitespace separates the arguments of :map. The mapleader is a built-in variable, and as such requires no escaping. You can simply use

:let mapleader = ' '

Alternatively, if you'd like to stick to the same notation, the keyword needs to be escaped and put in double quotes (cp. :help expr-quote):

:let mapleader = "\<Space>"
1

The problem was a missing \

let mapleader = "\<Space>"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.