You can use “cut” instead of “delete” and clipboard with history tracking, for example Alfred on macOS.
Then you cut, do some changes, and later on realize you wanted something from the cut code, bring out the clipboard history and fish out what you need.