How to use "Search and replace" in selected text in Sublime Text 3

2

I want to select text and then use "search and replace" to replace strings in this selection.

I think the following workflow should be it:

  1. Select Text
  2. Ctrl+H to activate "search and replace"
  3. type the search term
  4. Tab or click in replace textbox
  5. type the replace term
  6. do the search and replace operation

However, when one of the text boxes already contains text than my text selection is deselected. This happens whenever I try to use search and replace.

How can I prevent Sublime from deselecting my selected text?

I already found following ressources, but they didn't help preventing the deselecting.

xaedes

Posted 2014-02-10T01:11:26.907

Reputation: 171

Got the same issue and I can't quite understand how the three friends who recommended Sublime Text to me missed that obvious shortcoming. Probably we're looking for the wrong search terms or something. +1 – 0xC0000022L – 2014-10-31T01:19:21.310

Answers

1

I'm not sure if this works on every platform, but (in the Linux version at least) even though the text no longer appears selected, the search/replace module(?) seems to know where the text was selected.

You can click the "In selection" control (the right-most button just to the left of the "Find What:" box - the icon is a dark rectangle with a light centre) and the search/replace will occur only in the text that was selected when you invoked it.

Unfortunately, the text stays deselected after you perform this operation, so you have to select it again if you want to do another operation in that same text, so it's still not great.

I'm assuming this is a feature that the developers don't actually use themselves (or maybe they don't even use their own product to develop it?) or it would have been fixed long since.

This may be more recent functionality than the date of your post (I'm using build 3065).

Wilson F

Posted 2014-02-10T01:11:26.907

Reputation: 157