How to only show files from file extensions in a whitelist in a Workspace?
-
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.
-
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.
-
-
This post is deleted! -
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:
Right click the thing that saysWorkspace
and selectAdd New Project
. Now the sidebar will look like this.
Right clickProject Name
and selectAdd Files from Directory...
(notAdd Folder
. Yes, this is confusing). Add the folder of interest. I selectedC:\\silly
from the folder browser dialog and now my project sidebar looks like this:
Go toWorkspace->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, liketxt
(for just txt files) orpy|md
(for Python and Markdown files).
Replace with:
<!-- \1 -->
.
Regular expressions onNow 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.
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 toWorkspace->Find in Projects...
from the project panel, and theFind in Projects
dialog will pop up. See the documentation here.
Suppose I wanted to restrict my search totxt
files andxml
files. That’s what the*.txt *.xml
is doing.
If you search, a bottom bar will pop up in Notepad++ showing your search results.