Emacs Init: isearch Whitespace Regex
In emacs isearch
(Alt+x isearch-forward
)
〔see Emacs: Search Text in Current File〕
, you can type a space and it will also search for hyphen
-
and
low line
_
and tab and newline.
This this very convenient.
Put this in your Emacs Init File:
;; for isearch-forward, make these equivalent: space newline tab hyphen underscore (setq search-whitespace-regexp "[-_ \t\n]+")
But sometimes you want literal. This command makes it easy to toggle.
(defun xah-toggle-search-whitespace () "Set `search-whitespace-regexp' to nil or includes hyphen lowline tab newline. URL `http://xahlee.info/emacs/emacs/emacs_isearch_space.html' Created: 2019-02-22 Version 2024-06-16" (interactive) (if search-whitespace-regexp (progn (setq search-whitespace-regexp nil) (message "search-whitespace-regexp set to nil.")) (progn (setq search-whitespace-regexp "[-_ \t\n]+") (message "search-whitespace-regexp set to hyphen lowline whitespace"))))
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