Powerful rollback for multiple edits (feature request?)
- “rollback to just before most recent save” for one, or all open tabs in one go
Why? After multiple edits in different files/tabs in a project, I typically do “Save All” and run some tests. Sometimes I want to go back to what I started with in the first place, but all files have changed. Hence: rollback, please!
The current "solution"is to “Save all”, “Close All” and reopen a bunch of files. Not very efficient.
in the current situation, as you’ve described, you do not start with your initial state as save all
did overwrite it. What do I miss?
In theory it should work if you use a scripting language or npp_exec and do a
beginUndoAction first, now modify your sources and do your tests and afterwards another
script calls endUndoAction and Undo.
I said in theory because I did not test.
You’re right, my initial description was not very accurate.
Consider this scenario:
1 - create a file and save it. This is V1.
2 - test
3 - add/change/update and save (V2)
2 - test
3 - add/change/update and save (V3)
4 - test and regret
5 - rollback to V2
Right now, you’d have to close the V2 version and reopen it to clear the Undo history.
A simple “Clear Undo History” button would be a good step.
Can you show us your debug-info?
Can be found under the ? menu.
Notepad++ v7.3.2 (32-bit)
Build time : Feb 12 2017 - 23:15:39
Path : C:\Program Files\Notepad++\notepad++.exe
Admin mode : OFF
Local Conf mode : OFF
OS : Windows 10 (32-bit)
Plugins : ColorPicker.dll ComparePlugin.dll mimeTools.dll NppConverter.dll NppExport.dll NppFTP.dll PluginManager.dll
I could offer a possible solution but therefore you would need to either install
nppexec or a scripting language plugin like python/lua script.
If you want to try to go this way, which plugin do you prefer?
The scripting plugins give you access to most of the functionality npp and scintilla offers.
But there is a need to learn that language if you want to extend functionality by your own.
NppExec is also powerful but more easy to use if you don’t have any programming skills.
mkupper last edited by
Harry D. Why are you doing the close-all and reopen-a-bunch-of-files steps? I take advantage of that npp remembers the tabs and position within each tab. You can do save-all and Alt-F4 out of NPP. It’ll remember all your tabs when you restart it.
I also take advantage of being able to open NPP session files. For some projects there’s a list of 20 or so files that I want to open each time in NPP. Under the File menu dropdown is Save-Session and Load-Session. The session files are XML though by default don’t have a file extension. I’ve saved session files for various projects to speed up opening the files related to those projects. You can do
"C:\Program Files\Notepad++\notepad++.exe" -openSession "%SESSIONFILE%"
and it will open the session for you. If npp is already running then you get more tabs opened.
I could see adding to npp a way to undo a single [Replace in All Opened Documents] if it was the last thing done. It would mean npp would need to keep track of which tabs had a match in the search part and to only do an undo on those tabs. Mixing up undo of Replace-in-All-Opened-Documents with undo of other edits seems like a nightmare. At present npp maintains a separate undo-chain for each tab. an undo-all would somehow be a separate chain that’s also merged with the chains for each tab.
I normally deal with versions and rollbacks for projects using robocopy. I usually work on drive C: and keep a scratchpad USB disk mounted at E: I have a batch file, rbe.bat, that runs robocopy from the current directly to the corresponding directory on E:. If I’m at c:\src\npp I’ll do “rbe /s” to update the E: drive copy of c:\src\npp. rbe will be running “robocopy c:\src\npp e:\src\npp /NJH /NJS /NDL /s” I’ll then make my changes on the C: copy. If I end up messing up and realize it’s better to start over I’ll grab the copy I made on E:. Sometimes I’ll want to keep multiple versions “just in case” and have a batch file named rbt.bat that similar to rbe but it drops the results in a subfolder named 2017-03-09-1457 The 1457 is the current hour/minute.
rbt.bat (pronounced rabbit in my mind) is nearly identical to rbe.bat except that it appends the yyyy-mm-dd-hhmm time stamp to the end of the destination path. I suppose I could make a rbv.bat that did numbered versions instead of time stamps.
Here’s whan rbe.bat looks like though I stripped out some special case handling for when I run it from D:
@echo off setlocal set SRCDRV=%CD:~0,2% set SRCDIR=%CD:~2% set DSTDRV=E: if /i "%SRCDRV%" == "C:" goto :rbe-c echo. echo 'rbe.bat' can't be used from drive %SRCDRV% echo. pause goto :eof :rbe-c set DEST=%DSTDRV%%SRCDIR% goto :run-copy :run-copy echo robocopy . "%DEST%" /NJH /NJS /NDL %* robocopy . "%DEST%" /NJH /NJS /NDL %* goto :eof
chcg last edited by
Seems like usage of a VCS (subversion, git, …) might make sense for this usecase. There you can store as much version you want under the same name and go back in history to any commited version.
@mkupper: Thanks for taking the time to write up this guide. It seems to cover all my requirements and then some. I am definitely going to give that a go.
As for Alt-F4, I dislike having to kill a program to make it do what I want, but I should get over that here.
Too bad sessions don’t have assigned file extensions. It would be easier to just double click on a session and having NPP open all the files for you.
But, the title of this thread has “feature request?” in it. Maybe a workflow like yours will make it to a plugin or an extension to NPP. That would be very nice!