Working with sessions doesn't work very well here... and also erase the session file
-
Context:
I tend to use NP++ daily and have several groups of files that I have grouped into sessionsI work most of the time with two sets of text files with more than 15 files in each set - one group focused on work and the other focused on games. There is no file that is in both sessions.
I have associated these two session files so that they have the extension “.nps”(notepad session)
Files are not in the same directories/folders in each group generally.
To make things easier, I created a shortcut for each “.nps” session file (and placed them on the Desktop obviously), but there is also a shortcut for Notepad++ on the taskbar (and this opens and closes normally with the current session)
Sometimes, I use both groups simultaneously and this tends to be the source of the problems.
I’m aware of using the multiple instance configuration (it’s set to “Open session in a new instance”.
1-when I open the second session (after the first was opened) NP++ does not show the Document List as it should
2-if I configure the sessions to something other than “Open session in a new instance”, when I close and reopen NP++, it mixes the files and to solve this I have to remember to close all the files before closing NP++ to reopen it
3-if the session is already open (but I click on the shortcut for that session, NP++ doesn’t notice this and opens another instance with the same files
4-the most annoying problem is when I click on the shortcut of a session but NP++ also opens the other session even though I have closed all instances of NP++ (it seems that this happens because I didn’t close the files in the previous session when I closed it previously NP++)
5-When I modify a session by adding, removing or changing the order of files in NP++ and I intend to save the changes to the session, it only saves the path of the first session. ie. When I try to save a second session, NP++ suggests the default installation path.*6-There is a serious problem when I first open a session because NP++ simply deletes the content of one of the sessions, from the “.nps” file.i.e. one of the nps files runs out of content and I have to recreate it from scratch.
I don’t know if there is some setting I should be using or if it is a current issue in NP++
Thanks in advance
(google translator)–
Notepad++ v8.5.8 (64-bit)
Build time : Oct 15 2023 - 21:43:56
Path : C:\Program Files\Notepad++\notepad++.exe
Command Line : “E:\JOGOS_jogos 2023b.nps”
Admin mode : OFF
Local Conf mode : OFF
Cloud Config : OFF
OS Name : Windows 10 Pro (64-bit)
OS Version : 22H2
OS Build : 19045.3570
Current ANSI codepage : 1252
Plugins :
mimeTools (2.9)
NppConverter (4.5)
NppExport (0.4)–
----
moderator fixed “section” to “session” to fix bad translation -
@Theodore-Spittnikov said in Working with sections doesn't work very well here... and also erase the section file:
I have associated these two section files so that they have the extension “.nps”(notepad section)
“Sessions” ??
If so, perhaps you or a moderator could fix your post. -
1-when I open the second session (after the first was opened) NP++ does not show the Document List as it should
If you are in Notepad++ v8.4.9 or newer, Settings > Preferences > Multi-Instance and Date has checkboxes that you can use to configure which panels stay open even with multiple instances and which do not. If you have Notepad++ older than that, you should upgrade to get that feature.
2-if I configure the sessions to something other than “Open session in a new instance”, when I close and reopen NP++, it mixes the files and to solve this I have to remember to close all the files before closing NP++ to reopen it
A single Notepad++ instance only has one session that it thinks about, and it will auto-update that one session when it closes. That is how Notepad++ is designed.
3-if the session is already open, but I click on the shortcut for that session, NP++ doesn’t notice this and opens another instance with the same files
In “Open session in a new instance” mode, opening a session file will always open a new instance (it does not check whether the same session file is open in another instance). That is the way it’s designed.
4-the most annoying problem is when I click on the shortcut of a session but NP++ also opens the other session even though I have closed all instances of NP++ (it seems that this happens because I didn’t close the files in the previous session when I closed it previously NP++)
It only opens one session. You just effectively merged the sessions by opening old.nps then new.nps in the same session; when Notepad++ exited, it saw all the files open, and wrote them all to the active session file (sorry, I have never experimented with it, so I cannot say with certainty whether the “active session file” is the first session file opened or the most-recently opened session file). When you exit, Notepad++ will always assume that every file that is currently open is supposed to be part of the active session file. That’s the way that Notepad++ sessions are implemented and intended.
5-When I modify a session by adding, removing or changing the order of files in NP++ and I intend to save the changes to the session, it only saves the path of the first session. ie. When I try to save a second session, NP++ suggests the default installation path.
I don’t think I understand this one.
*6-There is a serious problem when I first open a session because NP++ simply deletes the content of one of the sessions, from the “.nps” file.i.e. one of the nps files runs out of content and I have to recreate it from scratch.
Do you have an exact sequence of events that replicates this?
My interpretation
Notepad++'s concept of a “session” seems to not match your concept of “session”, and its features might not be sufficient for your desires.
Workaround
Possible workaround: if you still feel you must use the “session” feature with your shortcuts, you could do a workaround instead:
- have four session files:
work.nps
,game.nps
,work-golden.nps
, andgame-golden.nps
- have your “work.lnk” shortcut run a batch file to
copy work-golden.nps work.nps
thennotepad++ -openSession work.nps
(and similar for “game.lnk”) - if you have even intentionally updated the active session file to add or remove files, then after you exited that Notepad++ instance, you would have to copy from
xxx.nps
toxxx-golden.nps
so that your “golden” version gets updated with the newest contents
Alternatives
The plugin “Session Manager” used to be recommended for improving Notepad++'s session-handling, but I don’t know if it would be sufficient for your needs, and it hasn’t been updated for years so might not fully work anymore.
You should look into Notepad++'s Project Panels instead. If you’ve only got 2 or 3 (which your use of “two sets of text files” seems to confirm), then each Project Panel can just permanently have one set of files (what I will call a “project workspace”, which were originally each of your main “sessions”), and you can give focus to either Project Panel 1 for “work” and Project Panel 2 for “game” (or however you chose to order it). (If you have more than 3 “project workspace” groups, you can either use multiple projects in the same “project workspace” to limit it, or you can use use the Load Workspace feature of the Project Panel to open a different “project workspace” when you want to switch.) My guess is that this would meet your described desires, but I’m not sure.
- have four session files:
-
@PeterJones said in Working with sessions doesn't work very well here... and also erase the session file:
*6-There is a serious problem when I first open a session because NP++ simply deletes the content of one of the sessions, from the “.nps” file.i.e. one of the nps files runs out of content and I have to recreate it from scratch.
Do you have an exact sequence of events that replicates this?
I think (did not check that myself yet) that this is what these patches are intended for:
Do not modify user created session even for inaccessible files
Fix user created session saved on exit issue if multi-Inst is enabled
Fix user created session modified in multiInst modeThese patches will be in the upcoming N++ version (probably v8.5.9).
And there will be the new read-only placeholders feature (for the momentarily inaccessible session files) as well.