Search code examples
vimremap

How to remap number keys and number key special characters in VIM


I am trying to remap the * operator in VIM. I have tried nnoremap <*> and nnoremap <S-8> to no avail. I haven't been able to find any instructions on how to properly do this. How can I remap my *, or any number keys/number key special characters?

Since many of you will no doubt wonder why anyone would want to do this, it's so I can make my * operator behave like normal, except not advance automatically to the next occurrence of the word under cursor (see under section Highlight Matches Without Moving).

EDIT:

The complete command I'm working with is this:

nnoremap <*> :let @/='\<<C-R>=expand("<cword>")<CR>\>'<CR>:set hls<CR>

Where * remaps the functionality of * or <shift + 8>


Solution

  • Getting rid of the < and > works for me.

    nnoremap * :let @/='\<<C-R>=expand("<cword>")<CR>\>'<CR>:set hls<CR>