Sublime Forum

The "Replace" field keeps remembering old text

#1

Hey all,

Something that drives me crazy. The “Replace” field in the “Search and replace in all files” feature, keeps remembering some text from a long time ago. Changing it, and reopening sublime, and it comes back in. How do I get rid of it?

Tried deleting the project and workspace file, still no change in behavior.

0 Likes

#2

Ok - I think I found the answer myself, this is way too sticky…

  1. I closed Sublime
  2. I deleted C:\Users\USER\AppData\Roaming\Sublime Text\Local\Session.sublime_session
  3. I deleted all *.sublime-workspace files from my entire drive

This behavior is quite annoying - I wish there was a setting to not remember old text - this text propagated to all my projects through that default session file I guess.

0 Likes

#3

I agree, being able to optionally always clear replace when using find & replace would be great.

0 Likes

#4

Behavior of find/replace panels can be customized via custom key bindings. The following example opens "replace" panel with replacement text cleared by passing "replace_pattern": "".

[
	{
		"keys": ["ctrl+h"],
		"command": "show_panel",
		"args": {
			"panel": "replace",
			// "pattern": "hello",
			"replace_pattern": "",
			// "reverse": false,
			// "regex": false,
			// "in_selection": false,
			// "whole_word": false,
			// "highlight": true,
			// "wrap": true
		},
	},
]

Note: pattern and replace_pattern are supported as of ST 4123.

2 Likes

#5

Oh - that is nice. Is there a reference of all the supported options for all the key bindings?
Found only this page, but it doesn’t seem to have that kind of information.

BTW - I was referring to the Ctrl+Shift+F dialog, but I am assuming it also supports this setting.

0 Likes

#6

Find in Files supports the same set of options.

	{
		"keys": ["ctrl+shift+f"],
		"command": "show_panel",
		"args": {
			"panel": "find_in_files",
			// "pattern": "hello",
			"replace_pattern": "",
			// "reverse": false,
			// "regex": false,
			// "in_selection": false,
			// "whole_word": false,
			// "preserve_case": true,
			// "use_gitignore": true,
			// "highlight": true,
			// "wrap": true
		},
	},

A list of known commands is maintained at https://docs.sublimetext.io/reference/commands.html#commands.

PackageDev supports auto-completion for commands within key bindings, which may provide some “reference” too. It currently struggles with the both available python plugin hosts running in parallel however. So you might not see all 3rd-party commands.

Both haven’t been updated to list all show_panel arguments however.

0 Likes

#7

Magnificent. Thanks.

(although I think this field does not have to be sticky in the first place - it is fine to keep it filled with the last used value, until I close sublime - the marked solution forces me to also lose the “session stickiness”).

0 Likes

#8

Shameless plug

3 Likes

#9

Nice plugin.

0 Likes