Community
    • Login

    is new tab next to current possible?

    Scheduled Pinned Locked Moved General Discussion
    7 Posts 3 Posters 2.1k 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.
    • patrickdrdP
      patrickdrd
      last edited by

      is new tab next to current,
      instead of creating at the end (last tab)
      is it possible?

      Claudia FrankC 1 Reply Last reply Reply Quote 0
      • Claudia FrankC
        Claudia Frank @patrickdrd
        last edited by Claudia Frank

        @patrickdrd

        afaik not natively but a python script could look like this

        current_index = notepad.getCurrentDocIndex(notepad.getCurrentView())
        notepad.new()
        new_index = notepad.getCurrentDocIndex(notepad.getCurrentView())
        for i in range(current_index+1,new_index): 
            notepad.menuCommand(44099)
        

        from nativeLang.xml

                        <Item id="44098" name="Move Tab Forward"/>
                        <Item id="44099" name="Move Tab Backward"/>
        

        Cheers
        Claudia

        1 Reply Last reply Reply Quote 1
        • patrickdrdP
          patrickdrd
          last edited by patrickdrd

          do you mean add that to my already existing startup.py?

          I did but I get two tabs when I launch npp and the code doesn’t seem to work:

          from Npp import editor, notepad, SCINTILLANOTIFICATION, NOTIFICATION, STATUSBARSECTION
          import os
          from datetime import datetime

          def StatusbarSelOverride(args):
          modified_time = os.path.getmtime(notepad.getCurrentFilename())
          last_modified_date = datetime.fromtimestamp(modified_time)
          notepad.setStatusBar(STATUSBARSECTION.DOCTYPE, ‘Mod: {:%d/%m/%Y %H:%M}’.format(last_modified_date))

          editor.callback(StatusbarSelOverride, [SCINTILLANOTIFICATION.UPDATEUI])
          notepad.callback(StatusbarSelOverride, [NOTIFICATION.READY])

          current_index = notepad.getCurrentDocIndex(notepad.getCurrentView())
          notepad.new()
          new_index = notepad.getCurrentDocIndex(notepad.getCurrentView())
          for i in range(current_index+1,new_index):
          notepad.menuCommand(44099)

          Claudia FrankC 1 Reply Last reply Reply Quote 0
          • Claudia FrankC
            Claudia Frank @patrickdrd
            last edited by

            @patrickdrd

            sorry for not being clear.

            No, create a new script and assign the same shortcut which is assigned for
            standard open new document action (normally ctrl+n).

            This solution, obviously, works only if you open new documents by using the shortcut
            but not if you use the mouse.

            Does this makes sense to you?

            Cheers
            Claudia

            1 Reply Last reply Reply Quote 1
            • patrickdrdP
              patrickdrd
              last edited by

              almost…

              how do I assign a shortcut to it?

              I searched in modify shortcut and script configuration but I couldn’t find it

              Scott SumnerS 1 Reply Last reply Reply Quote 0
              • Scott SumnerS
                Scott Sumner @patrickdrd
                last edited by Scott Sumner

                @patrickdrd

                You have to go into Plugins -> PythonScript -> Configuration and add your script to the Menu items area. After that it will appear in the Shortcut Mapper and you can assign a keycombo to it. [A restart of N++ is necessary before the changes to the PS config get picked up by the Shortcut Mapper…]

                1 Reply Last reply Reply Quote 4
                • patrickdrdP
                  patrickdrd
                  last edited by

                  thanks a lot claudia and scott!

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