@notdodgeball said in Notepad++ open in new instance because I use multiple desktops:
This disregard of openSession I never fully understood, as to me it should behave much like you just described.
I regularly use, or perhaps abuse, -openSession. A whie back I created a batch file, nplist.bat, that extracts file paths from a text file and generates a session.xml file. It then runs Notepad++.exe with -openSession. While I could have just run Notepad++.exe and passed the file names directly to it. I created nplist.bat because I wanted something that allowed me to open thousands of files at once. I did not think thousands of files would fit on the command line and was not comfortable with starting Notepad++.exe thousands of times and having those pass the file name on to the running copy of Notepad++.exe.
Notepad++ must already have some sort of inter-process communication (IPC) that allows a newly loaded copy of Notepad++.exe to tell the main running instance of Notepad+exe to come to the foreground and to open one or more files.
That means I should be able to create an run-npp.exe that implements the -instance logic I proposed earlier. The easiest way to define and separate instances of Notepad++ would be to use portable copies. I’d put them in
c:\npp\apple\Notepad++.exe
c:\npp\banana\Notepad++.exe
c:\npp\strawberry\Notepad++.exe
This allows each instance of Notepad++ to live in its own world. This assumes that whatever IPC Notepad++ uses is something that allows for multiple copies of the .exe to run at the same time and for an external app to talk to them. If, for example, Notepad++ is using a named pipe with a fixed name then only one copy can own the pipe.
What want is the ability to tell an already running instance of Notepad++.exe to open a file. For example, I want to open fruit.txt in Notepad++ and want to use the banana instance of Notepad++.exe to view or work with this file.