Sunday, April 3, 2011

Re: Backwards searches and the ? operator

On 04/03/2011 12:46 PM, Spiros Bousbouras wrote:
> I've just had some very frustrating minutes trying to figure out why
> searching with a pattern which I felt should work wasn't actually
> working. After trying this and that I decided eventually to look up
> \? in the help file and saw that it's not supposed to work with
> backwards searches. Does anyone know why this restriction exists ?
> Seems like a strange one.

Prefixed by the slash, it searches for a literal question-mark.
Without the prefixing slash, it terminates the search-re portion
of the query and delineates the flags (":help search-offset")
that are expected to follow.

A couple options if you want:

1) assign it with a forward-search, then perform a backwards
search with an empty RE:

/pattern with \? in it<cr>
?<cr>

2) assign it manually, then search backwards as before:

:let @/='my pattern with \? in it'<cr>
?<cr>

3) as you've discovered, just use "\=" instead :)

-tim

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: