• Login
Community
  • Login

Showing File-Path in Tab or above editor window

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
17 Posts 5 Posters 3.0k 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.
  • S
    Stimmenhotel
    last edited by Jul 10, 2023, 9:37 AM

    Hello,

    since I am using NP++ with many files sharing the same name, I am searching a way to show the file path in the tab or like directly below the tab inside the editor window.
    The files differ only form the path I am opening them from.
    They are located inside different project folders and in temporary paths from FTP-Clients.

    I found a way to show it in the document list, but since I am not using this, it is no solution.

    Is there a way to show the path in the tab or like a header ontop of the editor window?
    Maybe using a modifed theme?

    Thanks

    Br
    Stimmenhotel

    A M 2 Replies Last reply Jul 10, 2023, 12:44 PM Reply Quote 0
    • G
      guy038
      last edited by Jul 10, 2023, 10:01 AM

      Hello, @stimmenhotel and All,

      I suppose that the option, below, in Settings > Preferences... > MISC must be checked. In this case, just uncheck it !

      324d4750-2afc-485d-b500-7320426097e1-Stimmenhotel.png

      Best Regards,

      guy038

      S 1 Reply Last reply Jul 10, 2023, 10:09 AM Reply Quote 1
      • S
        Stimmenhotel @guy038
        last edited by Jul 10, 2023, 10:09 AM

        @guy038 Thanks for the quick tip!
        I have the path in the title bar, but is usally not the place my eyes are used to look. I will try to look more often on the titlebar, but I hoped there is maybe another way too.

        A 1 Reply Last reply Jul 10, 2023, 10:57 AM Reply Quote 1
        • A
          Alan Kilborn @Stimmenhotel
          last edited by Jul 10, 2023, 10:57 AM

          @Stimmenhotel

          The titlebar approach works if the tab you are interested in is the active one. Hovering the mouse over an inactive tab will cause a little popup to appear with the full path of the tab in it.

          1 Reply Last reply Reply Quote 2
          • A
            Alan Kilborn @Stimmenhotel
            last edited by Alan Kilborn Jul 10, 2023, 12:49 PM Jul 10, 2023, 12:44 PM

            @Stimmenhotel

            What’s your end goal?
            I presume it is to switch to the tab at a definite path (that you have in mind but can’t immediately see), but I wanted to make sure this would be your next step…

            1 Reply Last reply Reply Quote 0
            • M
              mkupper @Stimmenhotel
              last edited by Jul 10, 2023, 2:36 PM

              @Stimmenhotel Please see https://community.notepad-plus-plus.org/topic/24627/rename-the-tab-not-the-file which is similar to what you are asking about.

              A 1 Reply Last reply Jul 10, 2023, 2:53 PM Reply Quote 0
              • A
                Alan Kilborn @mkupper
                last edited by Jul 10, 2023, 2:53 PM

                @mkupper said in Showing File-Path in Tab or above editor window:

                which is similar to what you are asking about

                I don’t think the OP here wants to rename tabs…

                1 Reply Last reply Reply Quote 0
                • M
                  Mark Olson
                  last edited by Jul 10, 2023, 5:16 PM

                  Sadly, this is yet another person who would have benefited from my recent PR that enabled showing the directory or the path in the tab bar.

                  I’m not even going to suggest that the OP raise an issue, because it will just get rejected as a duplicate. ☹️

                  A M 2 Replies Last reply Jul 11, 2023, 1:06 PM Reply Quote 4
                  • S
                    Stimmenhotel
                    last edited by Jul 11, 2023, 6:17 AM

                    To add further information:

                    I am working with a few configuration files, one of them is on a test system inside a TEMP folder managed by WinSCP.
                    The files have the same name, as I often compare them and check for errors and/or similarities.

                    I think renaming tabs would not be possible, as the temp folder sometimes changes. Same for colorcoding.
                    Also I am not exclusively use NP++ for this case, so closing and opening tabs, workfolders, searching, etc. happens a lot.

                    @Mark-Olson That would have nailed the problem, yes. Sadly it was rejected.
                    Does it still make sense to add a comment to the PR?
                    Maybe this can be added as a plugin?

                    I think I will stay with temporary coloring for now or change the read-only status.

                    Thanks for your suggestions.

                    M 1 Reply Last reply Jul 11, 2023, 5:27 PM Reply Quote 1
                    • A
                      Alan Kilborn @Mark Olson
                      last edited by Jul 11, 2023, 1:06 PM

                      @Mark-Olson said in Showing File-Path in Tab or above editor window:

                      Sadly, this is yet another person who would have benefited from my recent PR that enabled showing the directory or the path in the tab bar.

                      I’m not even going to suggest that the OP raise an issue, because it will just get rejected as a duplicate.

                      Yes, but OP could add a comment in the rejected issue; this would help show the author that the functionality is important to yet another person.

                      1 Reply Last reply Reply Quote 3
                      • A
                        Alan Kilborn
                        last edited by PeterJones Jan 14, 2024, 6:31 PM Jul 11, 2023, 1:14 PM

                        Perhaps a script helps here…

                        Maybe when you need to go to a specific file that you see over and over in your tabs (“So which tab do I want??”), you run a script and it shows you all of the paths to these same-named tabs, and from there you could double-click the one you need to navigate to, and it would take you there; example:

                        6987046c-419c-42e4-9933-ae90181f38bf-image.png

                        I call the script ListDuplicatelyNamedTabsShowingFullPaths.py :

                        # -*- coding: utf-8 -*-
                        from __future__ import print_function
                        
                        #########################################
                        #
                        #  ListDuplicatelyNamedTabsShowingFullPaths (LDNTSFP)
                        #
                        #########################################
                        
                        # references:
                        #  https://community.notepad-plus-plus.org/topic/24685
                        
                        #-------------------------------------------------------------------------------
                        
                        from Npp import *
                        import inspect
                        import os
                        
                        #-------------------------------------------------------------------------------
                        
                        class LDNTSFP(object):
                        
                            def __init__(self):
                        
                                self.this_script_name = inspect.getframeinfo(inspect.currentframe()).filename.split(os.sep)[-1].rsplit('.', 1)[0]
                        
                                self.this_script_path_without_ext = inspect.getframeinfo(inspect.currentframe()).filename.rsplit('.', 1)[0]
                                self.results_file = self.this_script_path_without_ext + '.txt'
                        
                                self.original_file = None
                        
                                editor.callback(self.doubleclick_callback, [SCINTILLANOTIFICATION.DOUBLECLICK])
                        
                            def run(self):
                        
                                pathlist_by_tabtext_dict = {}
                        
                                view_0_tabtext_list = []  # for detecting cloned-files
                        
                                for (pathname, buffer_id, index, view) in notepad.getFiles():
                                    if not os.path.isfile(pathname): continue  # skip any soft-named tabs
                                    tab_text = pathname.rsplit(os.sep, 1)[-1]
                                    if view == 0:
                                        view_0_tabtext_list.append(tab_text)
                                    elif tab_text in view_0_tabtext_list:
                                        continue  # don't consider a cloned file as a duplicate tab for purposes of this script
                                    if tab_text not in pathlist_by_tabtext_dict:
                                        pathlist_by_tabtext_dict[tab_text] = [ pathname ]
                                    else:
                                        pathlist_by_tabtext_dict[tab_text].append(pathname)
                        
                                results_file_line_list = [
                                    'DOUBLE-CLICK A PATHNAME LINE TO CLOSE THIS FILE AND OPEN THAT PATHNAME',
                                    'DOUBLE-CLICK SOMEWHERE IN WHITESPACE TO CLOSE THIS FILE AND RETURN TO ORIGINAL FILE',
                                    '',
                                ]
                        
                                have_at_least_one_duplicate_tab_name = False
                        
                                for tab_text in pathlist_by_tabtext_dict:
                                    if len(pathlist_by_tabtext_dict[tab_text]) > 1:
                                        have_at_least_one_duplicate_tab_name = True
                                        results_file_line_list.append(tab_text + ' :')
                                        for path in pathlist_by_tabtext_dict[tab_text]:
                                            results_file_line_list.append('\t' + path)
                        
                                if have_at_least_one_duplicate_tab_name:
                        
                                    self.original_file = notepad.getCurrentFilename()
                        
                                    notepad.activateFile(self.results_file)  # in case it is already open
                                    if notepad.getCurrentFilename() != self.results_file:
                                        open(self.results_file, 'w').close()  # so notepad.open() won't prompt or fail on non-existent file
                                        notepad.open(self.results_file)
                                        assert notepad.getCurrentFilename() == self.results_file
                        
                                    eol = ['\r\n', '\r', '\n'][editor.getEOLMode()]
                                    editor.setText(eol.join(results_file_line_list))
                                    notepad.save()
                                    editor.setReadOnly(True)
                        
                                else:
                        
                                    self.mb('Currently there are no duplicately named tabs.')
                        
                            def doubleclick_callback(self, args):
                        
                                if notepad.getCurrentFilename() == self.results_file:
                        
                                    double_click_pos = args['position']
                        
                                    if double_click_pos == -1:
                        
                                        # not close to any text; simply return to original document
                                        notepad.close()  # close the file double-clicked in
                                        if self.original_file is not None:
                                            notepad.activateFile(self.original_file)
                                            self.original_file = None
                        
                                    else:
                        
                                        double_click_line = editor.lineFromPosition(double_click_pos)
                                        dclick_line_content = editor.getLine(double_click_line)
                                        pathname_to_open = dclick_line_content.strip()
                                        if os.path.isfile(pathname_to_open):
                                            notepad.close()  # close the file double-clicked in
                                            notepad.activateFile(pathname_to_open)
                                            self.original_file = None
                        
                            def mb(self, msg, flags=0, title=''):  # a message-box function
                                return notepad.messageBox(msg, title if title else self.this_script_name, flags)
                        
                        #-------------------------------------------------------------------------------
                        
                        if __name__ == '__main__':
                            try:
                                ldntsfp
                            except NameError:
                                ldntsfp = LDNTSFP()
                            ldntsfp.run()
                        

                        The script opens a new file and then waits for you to do something (i.e., double-click) in that file. When that happens, this special file closes and you are back on your way with what you need to work on next.

                        –
                        Moderator EDIT (2024-Jan-14): The author of the script has found a fairly serious bug with the code published here for those that use Mac-style or Linux-style line-endings in their files. The logic for Mac and Linux was reversed, and thus if the script was used on one type of file, the line-endings for the opposite type of file could end up in the file after the script is run. This is insidious, because unless one works with visible line-endings turned on, this is likely not noticed. Some detail on the problem is HERE. The script above has been corrected per that instruction.

                        1 Reply Last reply Reply Quote 3
                        • A Alan Kilborn referenced this topic on Jul 11, 2023, 1:14 PM
                        • M
                          Mark Olson @Stimmenhotel
                          last edited by Jul 11, 2023, 5:27 PM

                          @Stimmenhotel said in Showing File-Path in Tab or above editor window:
                          I’m glad that you think my PR would have been useful!

                          Maybe this can be added as a plugin?

                          In any case, the NavigateTo plugin is good for working with large numbers of files in general, and it’s also pretty good for dealing with files that have duplicate filenames.

                          6aeadafa-eaa9-4a1d-b66d-b6c74c0043dd-image.png

                          As shown in the above example, NavigateTo is really useful for sifting through files that may have the same name or similar names. If you do decide to use NavigateTo, I highly recommend downloading a recent release.

                          S 1 Reply Last reply Jul 13, 2023, 7:11 AM Reply Quote 3
                          • A
                            Alan Kilborn
                            last edited by Jul 11, 2023, 8:27 PM

                            Here’s NavigateTo showing my fileset…not bad:

                            b0daa1ec-817f-4a3e-ade2-f47588b26c0b-image.png

                            1 Reply Last reply Reply Quote 1
                            • S
                              Stimmenhotel @Mark Olson
                              last edited by Jul 13, 2023, 7:11 AM

                              @Mark-Olson Quite clunky, but perfect for now. Thanks for the recommendation.
                              @Alan-Kilborn Thanks for the script, I will try it anyway. Especially as it shows me the way of using scripts, I will definitely try it anyway.

                              A 1 Reply Last reply Jul 13, 2023, 11:41 AM Reply Quote 0
                              • A
                                Alan Kilborn @Stimmenhotel
                                last edited by Jul 13, 2023, 11:41 AM

                                @Stimmenhotel said in Showing File-Path in Tab or above editor window:

                                Quite clunky

                                I think you mean the NavigateTo approach?

                                I find invoking that plugin clunky (in the sense of keyboard usage) and have made a suggestion that it should be made better; see HERE.

                                1 Reply Last reply Reply Quote 0
                                • M
                                  Mark Olson @Mark Olson
                                  last edited by Jul 15, 2023, 7:41 PM

                                  @Mark-Olson said in Showing File-Path in Tab or above editor window:

                                  Sadly, this is yet another person who would have benefited from my recent PR that enabled showing the directory or the path in the tab bar.

                                  After a little more discussion, the PR that I mentioned above is firmly rejected, so there is definitely no point in trying to comment there.

                                  Maybe there is some other way that might get accepted to change Notepad++ directly to make duplicate files easier to work with, but it seems doubtful to me.

                                  1 Reply Last reply Reply Quote 0
                                  • A
                                    Alan Kilborn
                                    last edited by Jan 14, 2024, 8:59 PM

                                    If you’ve used a script in this thread, you might want to double check your copy of it for a bug I’ve discovered.
                                    Look to previous postings in this topic thread where the script has been changed – find the text moderator edit (2024-Jan-14).
                                    There’s a link there that describes the bug in more detail, and shows what needs to be changed in an old copy (or you can simply grab a copy of the current version).

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