• Login
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.
  • P
    patrickdrd
    last edited by May 8, 2018, 10:13 AM

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

    C 1 Reply Last reply May 8, 2018, 11:07 AM Reply Quote 0
    • C
      Claudia Frank @patrickdrd
      last edited by Claudia Frank May 8, 2018, 11:07 AM May 8, 2018, 11:07 AM

      @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
      • P
        patrickdrd
        last edited by patrickdrd May 8, 2018, 11:31 AM May 8, 2018, 11:30 AM

        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)

        C 1 Reply Last reply May 8, 2018, 11:35 AM Reply Quote 0
        • C
          Claudia Frank @patrickdrd
          last edited by May 8, 2018, 11:35 AM

          @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
          • P
            patrickdrd
            last edited by May 8, 2018, 11:49 AM

            almost…

            how do I assign a shortcut to it?

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

            S 1 Reply Last reply May 8, 2018, 12:11 PM Reply Quote 0
            • S
              Scott Sumner @patrickdrd
              last edited by Scott Sumner May 8, 2018, 12:13 PM May 8, 2018, 12:11 PM

              @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
              • P
                patrickdrd
                last edited by May 8, 2018, 12:15 PM

                thanks a lot claudia and scott!

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