Emacs: xah-find.el, Find Replace in Pure Elisp

By Xah Lee. Date: . Last updated: .

“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.

emacs xah-find 2018-08-30 6bbd9
emacs xah-find

This package provides these commands:


github: https://github.com/xahlee/xah-find

MELPA: http://melpa.org/#/xah-find [see Emacs: How to Install Packages Using ELPA, MELPA]


• 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 Calling Unix 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

emacs xah-find.el demo

Emacs Find Replace

  1. Search Text in Buffer
  2. isearch Current Word
  3. Isearch Whitespace Regex
  4. Highlight Text in Buffer
  5. List Delete Highlight Sort Lines
  6. Search Text in Directory
  7. Find Replace in Buffer
  8. Find Replace in Directory
  9. xah-find.el, Find Replace in Pure Elisp
  10. Regex Tutorial

Find Replace Scripts

  1. Golang: Find String (grep)
  2. Golang: Find Replace Script
  3. Python: Find Replace in a Dir
  4. Python: Find Replace by Regex
  5. Perl: Find Replace String Pairs in Directory
  6. Elisp: Write grep
  7. Emacs: xah-find.el, Find Replace in Pure Elisp

If you have a question, put $5 at patreon and message me.
Or Buy Xah Emacs Tutorial
Or buy a nice keyboard: Best Keyboards for Emacs


Emacs Lisp