Tip 793 Printable Monobook Previous Next
created September 17, 2004 · complexity basic · author mosh · version 6.0
This builds on two previous tips to search for sentences.
What: To re-search for a phrase again, ignoring space differences.
How: Visually select a phrase with the mouse and press // to find the phrase again (modulo spaces).
:vmap <silent> // y/<C-R>=substitute(escape(@", '\\/.*$^~[]'),"[ \\t\\r\\n]\\+","\\\\_s\\\\+","g")<CR><CR>
It escapes metachars in selection, and changes spaces in selection to generic space+.
Post might garble the backslashes in the mapping above, it has 2,2,2,2,2,4,4 backslashes.
See VimTip780.
Comments
You mean, the line
:vmap ....
goes into my vimrc, and it maps // in visual mode to a search-phrase command?