Emacs: Search Text in Directory
Find Text in a Directory (requires grep)
- Alt+x
grep -
List all matching text of all files in the current directory.
(requires external
grepcommand.)The current directory is usually the folder the current opend file is in. You can first call
diredto a folder you want.It will prompt you like this:
grep --color -nH -e ▮sample input:
grep -nH -e "Cheshire" *htmlIf you want case insensitive search, add a
-iin the grep option.any command will work, as long as it output in grep format.
output in a
*grep*buffer.
Find Text in Nested Directories (requires grep)
Find text in directory and all subdirectories, you can call any of:
- Alt+x
rgrep -
Search all files in current directory and subdirectory.
emacs prompts for
- search text
- wildcard pattern for file name
- base dir
- Alt+x
lgrep -
Search only some files of current dir by using a regex on file names first.
- Alt+x
grep-find -
Use a combination of unix
grepandfindcommands.Example prompt:
find . -type f -print0 | xargs -0 -e grep -nH -e MySearchStr▮(the exact prompt depends on your Operating system.)
Search Text from Dired (requires grep)
- Alt+x
dired-do-find-regexp -
Find all matches for REGEXP in marked files or the file under cursor.
Requires the unix command
find,xargs,grep.
Show Matched Files in Dired (requires grep)
- Alt+x
find-dired -
Run unix
findcommand to list files and show them in dired.
Find Text in a Directory (no require grep)
Reference
Emacs Find Replace
- Emacs: Search Text
- Emacs: Find Replace
- Emacs: Find Replace, by Regex
- Emacs: Find Replace and Change Letter Case
- Emacs: Highlight Word, Line
- Emacs: List Matching Lines
- Emacs: Search Text in Directory
- Emacs: Find Replace Text in Directory
- Emacs: Regular Expression
- Emacs Init: isearch Whitespace Regex
- Emacs Init: isearch by Arrow Keys
- Emacs Flaw: isearch Current Word
- Emacs: Search Current Word 📜
- Emacs: Xah Find Replace (xah-find.el) 📦