I like the behavior of the 'smartcase' option, which lets searches I type in by hand be case-insensitive by default, case-sensitive when there are any capital letters. I also like the behavior of the 'noignorecase' option, which lets searches generated by the editor (as when hitting * or #) be case-sensitive by default.
Unfortunately, 'smartcase' only does its magic when 'ignorecase' is on, so now I have a conflict: I can either get the nice behavior for hand-generated searches or the nice behavior for machine-generated searches, but not both.
How I can I get both nice behaviors?
:nnoremap <silent> * :let @/='\C\<' . expand('<cword>') . '\>'<CR>n(the last S stands for "solution";) – Vitor Jul 29 '15 at 13:17nnoremap, the*key doesn't seem to do anything. – Daniel Wagner Jul 29 '15 at 21:27<silent>in the wrong place -- as did garyjohn! Your code works well, thanks. – Daniel Wagner Jul 29 '15 at 21:35init.vimwhen I switched, and it has continued to work just fine. – Daniel Wagner Dec 22 '22 at 17:54