is new tab next to current possible?



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



  • @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



  • 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)



  • @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



  • almost…

    how do I assign a shortcut to it?

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



  • @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…]



  • thanks a lot claudia and scott!


Log in to reply