I’d like to revive the discussion about the “Enable session snapshot and periodic backup” checkbox becoming unchecked. It doesn’t seem like a desirable behavior, regardless of how the feature is meant to be used.

I rarely use multiple instances of NPP. Every time I do, the session snapshot and periodic backup box becomes unchecked. Re-checking the box restarts backups immediately, and in the specified directory, but the box comes unticked after an indeterminate amount of time regardless of whether I’ve opened a second instance of NPP since the last occurrence.

Apologies for commenting on a 6 months old thread but after trying to figure out what was going wrong with my notepad++, I came across this thread which finally made me figure out the issue and made me realise I have an alternate use case that is probably worth highlighting.

I make heavy use of Phabricator coupled with git for version control. As part of this, whenever I create a new change request for a repository, I have to run the command arc diff from gitbash on my Windows computer. This will open a text editor of my choice where I: fill in details of the commit, save and then close the text editor.

For a while now I have noticed the “Enable session snapshot and periodic backup” option will randomly un-tick itself wiping out my unsaved files. I have been unable to determine why this is happening for ages however this thread had made me realise that it is my frequent running of the arc diff command which is causing the option to un-tick.

The following use case is causing it to happen:

Close notepad++ with multiple unsaved documents and the backup option ticked

Find a way to modify the notepad++ command so that it doesn’t break my normal notepad++ setup

I say this because Notepad++ is really more designed to either always be used with sessions, or never be used with sessions. To try to mix the two behaviors is risky.

The two ideas I would try, if it were me having this problem:

Does the arc diff work if you just set it to a normal "C:\Program Files (x86)\Notepad++\notepad++.exe\" without the -multiInst -nosession options? Because that way, Notepad++ wouldn’t be changing between the two modes and getting confused.

My second idea would be to grab a second copy of Notepad++ – this time, the “portable” (the zip or 7z file from the downloads page), and put it in a different location. You could then have your normal notepad++, with all the file associations, stay on the installed copy; you could then point arc diff to the portable copy, which would always be opened in -multiInst -nosession, so it wouldn’t have any change of state there, either.

----

Some unsolicited advice: You said,

Close notepad++ with multiple unsaved documents and the backup option ticked

My unsolicited advice to you would be to not rely on long-term “unnamed” file storage. Taking ownership and control of your own files, including backups and version control, is something very important; there are times when events outside of Notepad++ control will cause the Notepad++ “unsaved file” saved location to be corrupted, and you may lose data. My personal advice is save early, save often; commit early, commit often. This is not something that’s unique to Notepad++; I have had the auto-saves by MS Word get corrupted when something goes wrong with Windows. Basically, if you are not in full control of your saves and your backups/version control, there is always the chance that a random Windows issue will cause data loss, whatever application you are running to manipulate the data.

I had a go at changing the arc diff command to only run "C:\Program Files (x86)\Notepad++\notepad++.exe\" however Phabricator did not like this at all.

The file for the commit opened in my already open notepad++ window but when I tried to save, it complained I needed to reopen notepad++ so that it was running as Administrator. I reran the test with notepad++ opened as Administrator but when I tried to save, it simply stated “Save Failed: Please check if this file is opened in another program”

I then tried to modify my command to run as "C:\Program Files (x86)\Notepad++\notepad++.exe\" -multiInst. This was technically better in that I was able to save my commit however, in this case it opened an additional copy of all the files I already had open in notepad++ (including both saved and unsaved documents). I then had to close not just the tab for the commit but the entire window containing the additionally opened copy of all my files. As such this doesn’t seem like the preferred option either.

The above 2 tests probably explain why the recommended command from Phabricator included -multiInst -nosession in the first place.

To confirm, installing an additional copy of notepad++ seems to work though it very much feels like a workaround.

The point at which I need 2 installations of notepad++ on my computer to ensure running the arc diff command doesn’t disable backups makes me think I would be better specifically setting arc diff to use an editor other than notepad++ (eg vim which is pre-installed with gitbash)

Yes, this is the Community forum – the community of Notepad++ users. This isn’t the feature-request/bug-report tracker (see the FAQ for that).

Your application didn’t work with Notepad++, so I provided some potential workarounds.

As another alternate workaround, instead of the portable Notepad++, create a shell script / batch file, and use that as the editor asscoiated with arc diff. The script would need to look something like the following .bat file:

@echo off
rem backup the config files
copy "%AppData%\Notepad++\config.xml" "%AppData%\Notepad++\config.xml.arcdiffbak"
copy "%AppData%\Notepad++\session.xml" "%AppData%\Notepad++\session.xml.arcdiffbak"
rem run notepad++ for the commit message
rem this is a blocking-instance, so the commit will wait for this instance of notepad++ to be exited
"c:\program files (x86)\notepad++\notepad++.exe" -multiInst -nosession %*
rem restore the config files
copy "%AppData%\Notepad++\config.xml.arcdiffbak" "%AppData%\Notepad++\config.xml"
copy "%AppData%\Notepad++\session.xml.arcdiffbak" "%AppData%\Notepad++\session.xml"

This creates a backup of your current config, runs notepad++; then, when you close notepad++, it will copy the backup config back.

I just used my command-line version of TortoiseSVN (which, like your Arcanist User Guide, wants an editor in blocking mode), and verified that the script above will properly be in blocking mode, and will make sure that it restores config.xml and session.xml to the pre-existing version once the temporary instance of Notepad++ is done.

PS: and thanks for prompting me to create that batch file… I’d not known (or forgotten) that the -multiInst -nosession put Notepad++ into blocking mode, so I hadn’t set Notepad++ as the editor for SVN; because of this, I am now able to. :-)

Thanks for the bat script suggestion.
I will have a look at that as an alternative. If I can’t get that working I will probably stick with the 2 notepad++ installations
It looks like there are multiple issues raised in github for this by the way (https://github.com/notepad-plus-plus/notepad-plus-plus/issues/4648) so we may get a permanent fix for it.

I use git on Windows, and the recommended solution for making git work with Notepad++ is:
$ git config core.editor
‘C:\Program Files (x86)\Notepad++\notepad++.exe’ -multiInst -notabbar -nosession -noPlugin

I would keep Notepad++ open all the time with multiple unsaved .txt files. I love this feature, that I can use Notepad++ as a scratch workspace, and that my session and edited text files are always backed up and can be restored in case of some sudden Windows crash or restart. It’s the #1 feature of Notepad++ to me.

Something would cause me to close Notepad++, like restarting Windows or having a mandatory Windows update that forcibly closed all apps.

Upon restarting Notepad++, my session was gone and the “Enable session snapshot and periodic backup” setting was cleared. I would have to find where Notepad++ was keeping my backups and I would carefully restore my session by hand. This would make me want to give up on Notepad++ and stop recommending it to others.

So, before giving up for good, I’m glad I found this thread. Unknowingly to me, the “Enable session snapshot and periodic backup” setting was getting cleared by using git.

Suggested solutions:

What if the -nosession flag caused the “Enable session snapshot and periodic backup” user preference to be disabled in the Preferences dialog box, and that this preference would not be persisted by this instance of Notepad++ (thus preserving the original value in the persisted user settings file)? OR

What if the -nosession flag did not save user settings at all and the user preferences dialog was disabled? OR

What if the -nosession flag caused a special no-session set of settings to be saved/loaded to/from a special “no-settings” user settings file?

With the way things are now, as I see it, no one should use Notepad++ with git.

as -multiinst and -nosession is incompatible with session snapshots and periodic backups, the best practice is, to keep your installed notepad++ as it is, and to use a secondary portable notepad++ for git.

download the notepad++ 7.6.6. portable version from >>> here <<<.
(the portable version does not require any installation and runs completely independent and isolated from your installed version. all custom settings, as well as any stuff you might want to try at the portable version, will not modify your installed version)

extract npp.7.6.6.bin.zip to e.g. C:\PortableApps\Notepad++.

open the C:\PortableApps\Notepad++ folder and start this portable version by double-clicking on notepad++.exe inside this folder.

This is particularly unfortunate because Git installer for Windows itself actually offers to set up Notepad++ as the default editor for commits.

Setting up a portable version just for this seems a bit too much, also it would then be annoying to manually keep both Notepad++ configurations in sync. It is sad, but I have decided to do the same as @Ron-Little and simply use Windows’ Notepad.exe for Git and avoid this problem altogether.