1

I'm struggling to map # to search selected in visual. What I've tried so far was vnoremap <silent> <#> y<ESC>/^R0<CR> (y ank selected, search / from ^R egister 0 and hit CR ), but it does not work. What is the right way to do this?

eugen-fried
  • 2,111
  • 3
  • 27
  • 48
  • 1
    Try that without the angle brackets <> around the #. – Pandu Aug 18 '13 at 09:46
  • See here: [Search for selection in vim](http://stackoverflow.com/q/363111/) – glts Aug 18 '13 at 10:18
  • Looks way too complicated for something that can be achieved with simple keymap. Shouldn't we make things easier (you know, it's the main programmer task in the end of the day :-)? – eugen-fried Aug 18 '13 at 10:27

1 Answers1

2
vnoremap # y/<C-r>0<CR>

# instead of <#>, <Esc> is redundant after y, and ^R should be <C-r>.

Nikita Kouevda
  • 5,508
  • 3
  • 27
  • 43