Add commandline parameter for no multiinstance

  • Hi, since W10 i am forced to go into multi-instance mode because the single instance mode does not create a new instance if one is not already exists on the same screen. This cause the screen to pop back to where NotePad++ is located.

    So i solved this issue with multi instance mode. It was a little getting used to but it works fine.

    What i need now is a parameter that makes it possible to open several documents, one after another, into the same session. Something like -nomultiinst or -useexisting.
    I’m using a script that uses notepad++ as viewer, that produces several log files. I would really like to have them end up in one session.

    If you get too many sessions you loose track of them.

  • @Hans-v-Buitenen ,

    If you want to a number of files all opened in the same instance while not interfering with other existing instances, just send all the filenames in the same command:

    notepad++  -nosession -multiInst "File1.txt" "File2.txt"

    opens both “File1.txt” and “File2.txt” in the same instance, while leaving my previous instance alone.

    notepad++ -nosession -multiInst *.*

    opens all the files in the current folder in one instance, while leaving any previous instances alone.

    However, you cannot add files to a specific/given instance on the command line if you are in multi-instance mode. That’s just the way multi-instance mode is defined.

  • I know that this works, but if you have a script that opens several files from different modules that would need some extra programming and it will delay the output.

  • @Hans-v-Buitenen ,

    This is the way Notepad++ works. If you have it in multi-instance mode, then each individual call to notepad++.exe opens a new instance with all the files given in the argument to that specific Notepad++ instance. You cannot pick and choose which already-running instance will get a new file (and I’ve never seen a multi-instance application that allows pick-and-choose of the destination window from the command line).

    In theory, you could make a feature request (per this linked FAQ) to ask for a way to pick a destination instance in multi-instance mode, but my guess is that it would be quite difficult to implement, and I don’t know whether you’d get traction with the developer(s). If you do create a feature request, make sure to paste a link to the issue in this discussion.

    Otherwise, you will need to build up a list of files that you want in the same instance, and either send them as arguments to a single run of notepad++.exe, or build a session file and ask notepad++.exe to open that session – but either way, it would need to wait until your script has gone and found all the files that it wants to group together. I’m not sure how that would take more than a second or two for any script to find; unless you’re trying to find a handful of files in thousands upon thousands of files, or from some slow remote server. For example, if your script currently says (in pseudocode)

    for file in all_files:
        if file meets criteria then
            launch `notepad++.exe file`
    next file

    then you could tweak it to say

    list_of_files = []
    for file in all_files:
        if file meets criteria then
            append file to list_of_files
    next file
    launch `notepad++ list_of_files`

    That’s not really a huge change to the coding of the script.

    Or, if you want everything in one instance anyway, don’t bother with multi-instance. Then, running new notepad++.exe commands will just add files to the one master instance.

    Or, if you really need multiple instances, open multiple instances, then from inside each instance, use one of the scripting plugins (like NppExec or PythonScript) to select and open files for that instance. By driving it from inside each instance, then files would be opened in the correct instance.

Log in to reply