I want to map Shift-k (K) as 5k but it is mapped to call a function vim.lsp.buf.hover()

These commands dont work:

map <S-k> 5k  
nmap <S-k> 5k  
noremap <S-k> 5k  
nnoremap <S-k> 5k  

Replacing <S-k> with <S-K> or K doesn't work.

:map K shows this:

n  K           *@<Cmd>lua vim.lsp.buf.hover()<CR>

1 Answer 1


I believe you have a <buffer> mapping that hides your mapping.

I would do:

:nnoremap <buffer> <S-k> 5k

Or if you want to do for all the buffers

:silent! bufdo nunmap <buffer> <S-k>
:nnoremap <S-k> 5k

Remark: The @ sign indicate that the mapping is buffer mapping.

More information about this with: :help map-listing.

  • This works only on that buffer where it run this command. adding it to init.lua doesnt help, have to source it in the buffer manually. Commented Oct 17, 2023 at 16:49
  • I have adapted the solution to make sure the corresponding <buffer> is deleted from all the open buffers. If you want to use it in your configuration you should probably set your mapping in an autocmd that is set after the autocmd that sets the <S-k> mapping. Commented Oct 17, 2023 at 20:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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