4

In my vimrc I have

nnoremap <Leader>h :bp<CR>
nnoremap <Leader>l :bn<CR>

But I have to source my vimrc to enable them with (:so $MYVIMRC). If I do a :map after starting vim I will see all my other shortcuts map with leader but not this one.

Their also so no other shortcut map to <Leader>h.

How this can happen?

I have the same problem with let @+=join([expand('%'), line(".")], ':')

My full vimrc

  • 3
    Your plugin might have unmapped. If your vimrc has the mapping and not overridden by plugin, it would have been shown. Which character you use for leader? – SibiCoder Jun 29 '16 at 17:59
  • 3
    You have defined mapleader after these mappings. The default leader is a `. So do \h` and \l work? – Peter Rincker Jun 29 '16 at 18:22
  • 3
    Run :verbose map <Leader>h to see what messed it up. – Sato Katsura Jun 29 '16 at 18:42
  • 1
    Your were right @PeterRincker leader was define after. Thanks a lot to all of you. PeterRincker can you post a quick answer so I can give you the karma? – Mio Jun 29 '16 at 21:57
7

From :h mapleader:

Note that the value of "mapleader" is used at the moment the mapping is defined. Changing "mapleader" after that has no effect for already defined mappings.

Your mapleader is changed after your mappings in question. Meaning your mappings will use the the default mapleader of a \. e.g. Your mappings will be \h and \l. Simply define your mapleader before all your mappings to get the effect you desire.

For more help see :h mapleader

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.