Emacs: Xah Find Replace (xah-find.el) ๐ฆ
- 2024-09-12 new
xah-find-undo-last-replace
- 2023-03-02 new command
xah-find-open-all
. - 2021-10-12 news. now
xah-find-replace-text
support dir depth min max level spec. Very useful for html relative links.
โxah-find.elโ is a emacs package for find/replace text.
This package provides emacs commands for find replace in a directory, similar to unix grep and sed, but written entirely in emacs lisp.
This package provides these commands:
xah-find-text
xah-find-text-regex
xah-find-count
xah-find-replace-text
xah-find-replace-text-regex
Get it by Donation
Goto paypal.com, send $32 to Xah@XahLee.org (be sure to include your correct email address. I need that to send it to you.)
Write in message area: xah-find.el
Features
- In output, press Enter on a link to jump to the file location. (or mouse click)
- In output, press โ and โ to jump to prev/next occurrence.
- In output, press โ or โ to move cursor to previous/next file name.
- When doing complex regex replace, you can do a test run to see possible changes without actually changing files.
- An undo replace command to revert last replace command.
โข No dependencies on unix/linux grep/sed/find. Especially useful on Microsoft Windows.
โข Output is highlighted and clickable for jumping to occurrence.
โข Pure emacs regex, not shell regex or python/perl regex. Exact same behavior in Linux or Mac or Windows.
โข Reliably Find Replace string that contains lots Unicode chars. No worry about file encoding used. Emacs takes care of it. The find replace string are sequence of chars, not bytes (or locale) as in grep/sed. See Linux Shell Util uniq Unicode Bug and Problems of grep in Emacs
โข Reliably Find Replace string that contains lots escape slashes or backslashes. For example, find replace source code that contains regex, or Microsoft Windows's file path.
โข Reliably Find Replace string that contains newline chars. These commands treat text to be searched as one big string (by emacs buffer), not as lines as in grep/sed or most programing language regexes. So it's much easier to search a block of text that contain newlines, search language source code. No need to deal with multi-line flags.
How to Use
Just call one of the commands. For example (Alt+x xah-find-replace-text
), it'll promp you for search string, replace string, directory, file path regex for filter, case sensitivity, whether to backup, etc.
Video Demo
- Xah Talk Show 2024-09-12 Ep585, Emacs Lisp, Find and Replace in a Dir, and Undo All
- Xah Talk Show 2023-03-02 Emacs Lisp Coding, Open All Files that Contains a Word, xah-find.el
Find Replace Scripts
Emacs Find Replace
- Emacs: Search Text in Current File
- Emacs: Search Current Word ๐
- Emacs Init: isearch Whitespace Regex
- Emacs Init: isearch by Arrow Keys
- Emacs: Highlight Word, Line
- Emacs: List Matching Lines
- Emacs: Search Text in Directory
- Emacs: Find Replace in Current File
- Emacs: Interactive Find Replace Text in Directory
- Emacs: Xah Find Replace (xah-find.el) ๐ฆ
- Emacs: Regular Expression