In most use cases I use * command just to highlight current word in source code to make sure that it was typed right for example.
How can I make star command to stay on current word?
If that is impossible, how can I bind another key to do that?
I think the simplest solution is this mapping:
:nnoremap * *``
where the last two characters are two backticks to restore the cursor to the original position. Another solution would be
:nnoremap * *N
but that moves the cursor to the beginning of the word. Both solutions have the disadvantage that your screen may scroll if the next match is off-screen. That could be fixed with a function--it just depends on the behavior you want and how much work you want to put into it.
Edit:
Just thought of another simple one that doesn't move the cursor at all.
:nmap <silent> * :let @/='\<'.expand('<cword>').'\>'<CR>
Quick hack:
:nnoremap * *N
This will perform a backward search after searching for the word under cursor with *
.