
A workspace-wide grep can mix current chapters with notes, archives, and old drafts. A selected-folder search protects those neighboring files by narrowing where the same query is allowed to run. In a controlled example, the word needle appeared three times across the workspace but only twice inside the selected folder. The result outside that folder did not appear.
Build a boundary you can observe
Place one.txt and two.txt in a selected folder and outside.txt in an excluded folder. Put the same query on line one of each file. A workspace search should return three matches; a selected-folder search should return the two inside files.
In a real writing project, use meaningful folders such as manuscript, notes, and archive. Choosing manuscript is clearer than relying on a filename prefix to exclude old material.
Search from the selected folder
Select the intended folder in the file tree and run the search within that scope. Read the returned path, line, and surrounding text for every match. The worked search returned line one of one.txt and line one of two.txt only.
If it returns zero, check the selected path, spelling, capitalization, character width, and file extension before broadening the search.
Prove the boundary with a comparison
Run the same query across the whole workspace. The example then returned the two inside matches plus excluded/outside.txt, for a total of three. The important evidence is not merely “two matches.” It is that the known outside path appears in the workspace result and is absent from the selected-folder result.
Review before replacing
Grep finds candidates; it does not decide that every candidate should change. Read context for quotations, names, or examples that must remain untouched. Before replacement, record the expected files and match count and keep a recoverable copy.
After replacement, search the same selected folder for both the old and new terms. Confirm the old term is gone only where intended, the new count is expected, and the excluded folder is unchanged.
If an outside file appears, stop and inspect the selected path. Choosing a parent folder naturally includes all of its children. Return to the intended child folder and search again.
This guide is about folder scope, not regular-expression design or workspace-wide replacement. The safest conclusion is to judge a selected-folder grep by what it excludes: compare the two inside matches with the three workspace matches before editing anything.