Community
    • Login

    Opening file with command line in an existing instance

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 1.2k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • E
      Eli Grey
      last edited by Eli Grey

      I want to open a file via command line in cmd to an existing instance. I know I can set setting to default(mono-instance) in preference settings -> multi-instance setting. But I don’t want to use mono-instance normally, I only want to use mono-instance via cmd.

      So is there any possible way to open file in as existing instance with cmd?, while multi-instance setting is on “always in multi-instance mode”.

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @Eli Grey
        last edited by

        @Eli-Grey said in Opening file with command line in an existing instance:

        there any possible way to open file in as existing instance with cmd?, while multi-instance setting is on “always in multi-instance mode”.

        No, but the opposite is easy: if you normally have notepad++ in mono-instance (via the settings), opening a single time in a separate instance from the command line is easy (with the -multiInst -nosession command line arguments)

        But, I suppose, if you have the normal settings (stored in %AppData%\Notepad++) with multi-instance enabled, you could run from the command line using an alternate settings directory. So

        1. Copy %AppData%\Notepad++\config.xml to some alternate directory (I will use the example c:\usr\local\apps\npp\altSettingsDir\config.xml)
        2. Edit that new config.xml, and <GUIConfig name="multiInst" setting="2" to <GUIConfig name="multiInst" setting="0" . Save
        3. From command line,
          • notepad++ change.log will open change.log using the normal multi-instance rules
          • the alternate notepad++ -settingsDir="c:\usr\local\apps\npp\altSettingsDir\" change.log will use the alternate config file location, and thus not use multi-instance mode, and it will pick one of the already-open Notepad++ instances for editing the file

        If you like that, you could set up a batch file in your path npp-mono.bat, which would call @notepad++ -settingsDir="c:\usr\local\apps\npp\altSettingsDir\" %*, so that you wouldn’t have to type that long -settingsDir argument every time.

        E 1 Reply Last reply Reply Quote 3
        • E
          Eli Grey @PeterJones
          last edited by

          @PeterJones Oh my gosh, that’s all I needed. Thank you so much, I made batch file also, it makes me so comfortable.

          1 Reply Last reply Reply Quote 2
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors