Sublime Forum

Prevent the text boxes in find/replace being auto-filled by text selected in the current file body

#1

Typical scenario:

  1. Press CTRL+F to open find.
  2. Enter some really long and often over+complicated regular expression.
  3. Many matches eventually highlight once I’ve got it right, along with the first match becoming selected.
  4. Press CTRL+H or CTRL+SHIFT+H to begin replacement.
  5. My complicated regular expression in the “find” input has been replaced with the first match that got automatically selected, and is not present in the find history.
  6. Keyboard bashed with fist then rammed in monitor out of frustration as the expression must be written out again.

Is there an option to disable this annoying (bad design) behaviour? When my keyboard focus was already on the “find” text box it shouldn’t be looking from the current file body for a replacement.

The current workarounds are before pressing CTRL+H or CTRL+SHIFT+F either:

  1. Ensure the “find” input is copied to clipboard or some safe place.
  2. Deselect the automatically selected match.

But those are workarounds and are easily forgotten. This behaviour should be avoidable.

Thanks,
Adam

0 Likes

#2

A third workaround for you:

  1. make sure to press enter/find/replace/any button, it’ll be added to the history
  2. when accidentally overwriting the find text, press up arrow & down arrow & the original search term will reappear
1 Like

#3

Turning this option off may solve your problem; it’s turned on by default:

	// If true, the selected text will be copied into the find panel when it's
	// shown.
	// On Mac, this value is overridden in the platform specific settings.
	"find_selected_text": true,
4 Likes

#4

That setting did the trick exactly, I can flip between the 3 modes of finding/replacing without the “find” input box being overwritten.

I tried by entering a simple regex [a-z]+\.[a-z_]+, and although a match did get highlighted, using the shortcut keys to change mode did not grab it to the “find” input box.

Thank you kindly.

1 Like

#5

Perfect, thanks @OdatNurd!I think the default setting should be reversed, to be:

"find_selected_text": false.

0 Likes