I think the answer you're looking for is Save without Formatting.
This command (workbench.action.files.saveWithoutFormatting
) will directly save the file as-is.
The issue with regular save, even if you don't have a formatter configured, is that there are still other routines that can run, like removing trailing spaces or ensuring there's a final newline at the end of the file. These changes push onto the undo stack replacing your redo history.
I disagree with the other answers that suggest disabling format-on-save; cleanly formatted code should be the default. When you want to test an older version of the code briefly, "Save without Formatting" lets you do so without interfering with the undo stack.
I have bound "Save without Formatting" to ctrl+shift+s
(which I believe was "Save All" by default) and I use it frequently when traversing my undo stack.
I also find this command useful when tools like eslint or scss langauge services start mis-behaving and interrupt the save process with excessive "on save" action delays, allowing me to save quickly now, allow the recompilation to trigger so I can test immediately, then I run the regular save command so that the "on save" actions can run in the background while I'm testing the saved but unformatted code.