I'm conditioned to hit Ctrl+S with almost every change, so this gives me a very detailed history of my revisions.
Probably very possible to extend that with some advanced vimscripting.
Makes me wonder honestly what tool in widespread use doesn’t have this? Notepad?
Sort of, anytime you delete something, that text gets stored somewhere in case, 2 hours later, you realised you wanted it.
Undoing a change from 2 hours ago in the same editing session is the trivial use case for undofile.
Took me a while to discover this but has saved me almost as many times as local history in a file. Also makes me feel much better when refactoring and deleting tons of old code.
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.
For this reason I comment out code then keep it until I’m sure I no longer need it. This works in sessions, and do the final delete, clean up etc at the end of the session before committing the changes to the repo. I see devs keeping commented out code in repos but that adds too much noise, makes the code a real mess..
You can even do a graphical diff against each candidate timestamp in a gui wizard
As others have mentioned JetBrains cloned this feature too
I'll often delete something, then work for a while, then realize I need that thing back again so I have to VERY carefully undo everything after the delete until I get to a point in history before it, copy the deleted text, then re-do everything back to my original state while making sure not to accidentally execute any inputs which would burn down the redo stack.