• Login
Community
  • Login

How to only show files from file extensions in a whitelist in a Workspace?

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
4 Posts 3 Posters 702 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.
  • W
    WolfyRed
    last edited by Apr 22, 2023, 12:35 PM

    How do I only show files from file extensions in a whitelist in a Workspace? Like, maybe only show “.txt”, “.text” files in the Workspace.

    A 1 Reply Last reply Apr 22, 2023, 12:46 PM Reply Quote 0
    • A
      Alan Kilborn @WolfyRed
      last edited by Alan Kilborn Apr 22, 2023, 12:49 PM Apr 22, 2023, 12:46 PM

      @WolfyRed

      It isn’t possible.

      I suppose you could put differently extensioned files into different projects within a workspace, and then collapse some projects and uncollapse other, but this might not be suitable to you.

      Oh, wait…maybe you mean Folder As Workspace? I was thinking of “Projects” type workspaces (N++ makes the nomenclature confusing in the project/workspace/folder-as-workspace arena).

      If you mean FAW, then really there is no way to do what you want.

      1 Reply Last reply Reply Quote 3
      • A Alan Kilborn referenced this topic on Apr 22, 2023, 12:50 PM
      • M
        Mark Olson
        last edited by Apr 22, 2023, 1:56 PM

        This post is deleted!
        1 Reply Last reply Reply Quote 0
        • M
          Mark Olson
          last edited by Mark Olson Apr 22, 2023, 2:43 PM Apr 22, 2023, 2:37 PM

          If you’re talking about Folder as Workspace, then yeah, I don’t know a good way to do this. If you want a workspace that contains one or more folders and you want to hide files in that workspace, I suppose what you could do would be to export the workspace to an XML file, and then edit it with find/replace to comment out the files you don’t want.

          Relevant documentation is here for discussion of project panels and here for discussion of searching the project panel.

          Suppose I have a folder like this:

          C:\\silly:
              - foo.txt
              - bar.xml
              - baz.txt
              - quz.py
          

          Creating a project panel

          I go to View->Project Panels->Project Panel 1 (assuming you don’t already have a Project Panel 1).
          You should get a sidebar that looks like this:
          b7296eb4-9540-47af-8a7d-c2877996addf-image.png
          Right click the thing that says Workspace and select Add New Project. Now the sidebar will look like this.
          29803dde-ff74-464f-afbb-3c5cf047d6a9-image.png
          Right click Project Name and select Add Files from Directory... (not Add Folder. Yes, this is confusing). Add the folder of interest. I selected C:\\silly from the folder browser dialog and now my project sidebar looks like this:
          10cbed10-e779-4430-8a31-e0b597b8d323-image.png
          Go to Workspace->Save As... and save your workspace as an XML file.

          Excluding some files from your project

          Now open up the project’s XML file in Notepad++. It will have the following contents:

          <NotepadPlus>
              <Project name="Project Name">
                  <File name="C:\silly\bar.xml" />
                  <File name="C:\silly\baz.txt" />
                  <File name="C:\silly\foo.txt" />
                  <File name="C:\silly\quz.py" />
              </Project>
          </NotepadPlus>
          

          Now find/replace in this file.
          Find: (?-si)(<.*name="[^"]*\.(?:txt|xml)"(?:(?!/>).)*?/>)

          • txt|xml can be any |-separated list of file extensions you want to exclude, like txt (for just txt files) or py|md (for Python and Markdown files).

          Replace with: <!-- \1 -->.
          Regular expressions on

          Now the file will look like this:

          <NotepadPlus>
              <Project name="Project Name">
                  <!-- <File name="C:\silly\bar.xml" /> -->
                  <!-- <File name="C:\silly\baz.txt" /> -->
                  <!-- <File name="C:\silly\foo.txt" /> -->
                  <File name="C:\silly\quz.py" />
              </Project>
          </NotepadPlus>
          

          Now save this file and close Notepad++ then reopen Notepad++. You need to close and reopen because Notepad++ doesn’t save the association between the project panel file and the project panel until it closes.
          You should now find that the Project Panel will no longer show any .txt or .xml files.
          3fb80c5e-8fe0-43ac-a32b-37aa34ba6c51-image.png
          If you later decide you want to uncomment only XML files so that those are revealed in the workspace, you can do that by find/replacing (?-si)<!-- (<.*name="[^"]*\.(?:xml)"(?:(?!/>).)*?/>) --> with \1 (regular expressions on). Then your project file will look like

          <NotepadPlus>
              <Project name="Project Name">
                  <File name="C:\silly\bar.xml" />
                  <!-- <File name="C:\silly\baz.txt" /> -->
                  <!-- <File name="C:\silly\foo.txt" /> -->
                  <File name="C:\silly\quz.py" />
              </Project>
          </NotepadPlus>
          

          Using Find in Projects to search only some files

          One way to make life easier would be to use the Find in Projects feature of the find/replace dialog to search your project. You just go to Workspace->Find in Projects... from the project panel, and the Find in Projects dialog will pop up. See the documentation here .
          8e658c10-8cc4-4c17-840a-560282c19473-image.png
          Suppose I wanted to restrict my search to txt files and xml files. That’s what the *.txt *.xml is doing.
          If you search, a bottom bar will pop up in Notepad++ showing your search results.

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