The key to use is C-S-RET
, not S-RET
. That's Control with Shift and Return.
And you do want to replace the whole context, if your context is text
. So option icicle-search-replace-whole-candidate-flag
should be non-nil
.
I think that answers your question, but here is some more info, in case it helps.
There are of course other ways to perform the simple replacement described.
Perhaps you narrowed down a more elaborate problem to this example, which gets to the heart of the problem you were having. But if not, let me point out two things:
Icicles search helps even in this simple case, if you just want to replace certain occurrences, on demand, rather than being queried for each occurrence. That's really the only advantage it offers for such a simple case.
And even for that there are other ways -- for example, if you use library Isearch+ then you can replace specific matches, on demand, using C-M-RET
.
Icicles search is especially for searching and replacing within defined contexts, not just replacing entire regexp matches.
For example, you might want to search only for occurrences of text
within matches for regexp is \(text\)[^ ]+
. In that case you'd provide that regexp and the number 1
, to define the context as matches for the first subgroup, which is \(text\)
. You'd then proceed the same way as for your example. That would exclude other occurrences of text
.
Even more generally, you might want to define the context that way, but then search for some text within matches for the context, e.g., search for xt
within the matches for text
within the matches for is \(text\)[^ ]+
.
In that case, you'd define the contexts the same way, but then use xt
as your minibuffer input, to, first, filter to only contexts that contain xt
(which doesn't do any filtering, in this case, since all matches for the context regexp contain xt
), and second, replace particular such occurrences of xt
.
To replace only matches for your minibuffer input (e.g. only the xt
in this case), you need to turn off option icicle-search-replace-whole-candidate-flag
, because you don't want to replace the entire search context, but just the part that matches your input. You can toggle the option value anytime during search using M-_
.
See Icicles - Search And Replace for more info.