Sublime Forum

Is there a way to search [and replace] within a selection?

#1

I’d like to be able to select a few lines of code and perform a search or a search+replace within the selection only, not just within the whole file. CTRL+F searches the whole file, and CRTL+H performs search and replace on the whole file.

0 Likes

#2

There is an option in Settings called auto_find_in_selection. Please, see below:

	// When auto_find_in_selection is enabled, the "Find in Selection" flag will
	// be enabled automatically when multiple lines of text are selected.
	// "find_only" or "replace_only" may also be used to only enable this
	// behavior for the find or replace panel respectively.
	"auto_find_in_selection": false,
1 Like

#3

Regardless of the setting mentioned above, you can toggle whether to search or replace in the selection from a button within the Find panel and the Replace panel. Hover over the buttons for tooltips to help you find it.

4 Likes

#4

As kingkeith says, you can use the Find button to skip over those selections that you do not want to replace and the Replace button for those that you want changed.

0 Likes