Community
    • Login

    Is there a way to open files in the left panel/view only?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 329 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.
    • T
      That-LEGO-Guy
      last edited by

      I always have the files i’m working on in the left panel/view and docs/notes/logs files etc. in the right panel, though frequently open files after having the right panel/view active
      like using the file://PATH/FILENAME link and have to move to other view

      1 Reply Last reply Reply Quote 0
      • Alan KilbornA
        Alan Kilborn
        last edited by

        Is there a way to open files in the left panel/view only?

        No, not normally.

        But this behavior can be scripted:

        # -*- coding: utf-8 -*-
        from __future__ import print_function  # Python2 vestige!
        
        #########################################
        #
        #  AlwaysOpenFilesIntoPrimaryViewTabs (AOFIPVT)
        #
        #########################################
        
        # note:
        #  This script was developed and tested under Python3 64-bit on unicode (non-ANSI) encoded data.
        #  It may work as-is using Python2 and/or ANSI-encoded data and/or 32-bits, but that would be incidental.
        
        # references:
        #  https://community.notepad-plus-plus.org/topic/26371/is-there-a-way-to-open-files-in-the-left-panel-view-only
        #  for newbie info on PythonScripts, see https://community.notepad-plus-plus.org/topic/23039/faq-desk-how-to-install-and-run-a-script-in-pythonscript
        
        #-------------------------------------------------------------------------------
        
        from Npp import *
        
        #-------------------------------------------------------------------------------
        
        class AOFIPVT(object):
        
            def __init__(self):
                self.recently_opened_buff_id = None
                notepad.callback(self.fileopened_callback, [NOTIFICATION.FILEOPENED])
                notepad.callback(self.bufferactivated_callback, [NOTIFICATION.BUFFERACTIVATED])
        
            def fileopened_callback(self, args):
                self.recently_opened_buff_id = args['bufferID']
        
            def bufferactivated_callback(self, args):
                if self.recently_opened_buff_id is not None:
                    if self.recently_opened_buff_id == args['bufferID']:
                        if notepad.getCurrentView() == 1:
                            notepad.menuCommand(MENUCOMMAND.VIEW_GOTO_ANOTHER_VIEW)
                    self.recently_opened_buff_id = None
        
        #-------------------------------------------------------------------------------
        
        ALWAYS_OPEN_FILES_INTO_PRIMARY_VIEW_TABS = AOFIPVT()
        

        Note that while using the script, you must move any tabs/files you want to be in the secondary view (the “right panel” in your terms) from the primary (“left”) view. What I’m trying to point out here is that if you attempt to drag (from Windows Explorer) and drop into the secondary/right view, the tab/file will immediately be moved to the primary/left view.

        To have the script start when Notepad++ starts up, put the following line into user startup.py:

        from AlwaysOpenFilesIntoPrimaryViewTabs import ALWAYS_OPEN_FILES_INTO_PRIMARY_VIEW_TABS

        and make sure that “Initialisation” for “Python Script Configuration” is set to “ATSTARTUP” and not “LAZY”.

        T 1 Reply Last reply Reply Quote 4
        • Alan KilbornA Alan Kilborn referenced this topic on
        • T
          That-LEGO-Guy @Alan Kilborn
          last edited by

          @Alan-Kilborn wow this is great, thankyou

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