Sublime Forum

What is the correct way to replace text in a selection?


I regularly want to replace items just in a selection. It should be straightforward but either I am doing something wrong or there is a bug. Lets work through the sequence I am trying.

I type in some text.
I have learnt not to select the text at this point as the selection is removed by the next step.
I type ctrl-H
I type the text I want to replace in Find:
I type the replacement text after Replace:
I select the text where I want the replacement to happen.
I click on the box which enables replacement “in selection” only. It would be nice if this was default when there is some text selected.
I click “Replace All”
The dialog disappears but no text is replaced.
I click ctrl-H again
I select the text again
I click “in selection” again
I click “Replace All”
This time the text IS replaced.
It seem to work every second time I try it.




Thank you for pointing out that someone else is also confused by this behaviour. Not sure why it is marked as trivial?
It seems I was wrong in my previous assertion that selecting in advance does not work. In fact it appears that it is how it is meant to work, however the highlighting on the screen showing what is selected disappears when you enter the find/replace dialog which led me to assume I had to make my selection after opening the dialog. But in fact making a selection that way does not work at all. In addition, even though there is some text (invisibly) selected it does not default to enabling “in selection”. I have to say I don’t find it very intuitive to use. Is it possible to change it so that the text highlighting is not removed, and to default to “in selection” if there is text selected when the dialog opens? Also allow the selection to be changed after the dialog has been opened. While I’m here can I also request that the dialog stays open after the replacement has been made?