2

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

2

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.

2
  • 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. Oct 17 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. Oct 17 at 20:02

Your Answer

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

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