bronson / vim-visual-star-search

Start a * or # search from a visual block
http://got-ravings.blogspot.com/2008/07/vim-pr0n-visual-search-mappings.html
181 stars 36 forks source link

make search strings that have tilde work properly #6

Closed slashfoo closed 8 years ago

slashfoo commented 8 years ago

same as last patch, this fixes stuff that contain a tilde, we probably need to do this with all the characters that have special meaning, and/or do some sort of global escaping to search for the exact string and not use it as a regular expression.

wellle commented 8 years ago

On a general note, wouldn't it make sense to use the "very nomagic" switch to avoid escaping everything? Just prepend \V to the search term and then only very few characters need escaping (I believe backslash and possibly slash). Try it by typing /\V[ab]. It will match literal [ab], but no single a or b.

See :h magic for a table of characters we might want to check.

If we decide to stick to escaping, consider using :h escape() instead of substituting.

slashfoo commented 8 years ago

@wellle yeah, I know about the flag, but it makes other things need to be escaped instead, so we're on the same boat. We should either do a literal search, or do a thorough test-through on the mode we choose.

bronson commented 8 years ago

I remember trying very nomagic and found more issues with the search string than the one we have now... don't remember exactly what, though. Could be a false memory. :)

I say try it. If it works everywhere, I'm for it. Especially if it can fix the TODO item at the top of the file.

Until then, this fix totally makes sense. Merged, thanks @slashfoo. Any other characters we should worry about...?

bronson commented 8 years ago

Hm, godlygeek handles this a little different... might be worth a look: https://github.com/godlygeek/vim-files/blob/871454686a5d05f9a84999232fb874fbd7a071f9/plugin/vsearch.vim