Since last week’s post was about Unicode characters, it makes sense to continue
that trend today. This feature might go unnoticed by a lot of people who live in
an ASCII world, but it will probably jump out at everyone else at one point or
another. The name, if a bit odd, is “character-folding search”.
In Emacs 25, Isearch can find a wide range of Unicode characters (like á, ⓐ, or
𝒶) when you search for ASCII characters (a in this example). To enable this
feature, set the variable search-default-mode to char-fold-to-regexp.
This first came up due to a new feature of a recent version of Texinfo, where
some markup styles are exported in “round quotes” when generating the info
manual. This is a nice improvement in readability, but when you’re trying to
search for something with C-s, things can get a little difficult if your
keyboard can’t type some of the characters.
With char-folding, when you hit C-s and search for ", Emacs will also search
for a variety of double quotes, from the aforementioned “” to many others like
«» and ❝❞. The same goes for the single quote, and for pretty much any other
ASCII character.
You could always type any Unicode character by name with C-x 8 RET, and many
of them even have their own shortcuts under C-x 8, but not having to type
them can be a significant convenience when it comes up. As any Brazilian, I am a
daily user of diacritical marks (ó, ã, ê, and the likes), and even though my
keyboard can type these characters, I still enjoy the simplicity of not having
to.
Finally, you can extend this feature to the query-replace command, which is
also as easy as setting a variable.
New in Emacs 25.1: Easily search for non-ASCII characters
02 Feb 2016, by Artur Malabarba.New in 25.1 post series
Since last week’s post was about Unicode characters, it makes sense to continue that trend today. This feature might go unnoticed by a lot of people who live in an ASCII world, but it will probably jump out at everyone else at one point or another. The name, if a bit odd, is “character-folding search”.
In Emacs 25, Isearch can find a wide range of Unicode characters (like á, ⓐ, or 𝒶) when you search for ASCII characters (
a
in this example). To enable this feature, set the variablesearch-default-mode
tochar-fold-to-regexp
.This first came up due to a new feature of a recent version of Texinfo, where some markup styles are exported in “round quotes” when generating the info manual. This is a nice improvement in readability, but when you’re trying to search for something with C-s, things can get a little difficult if your keyboard can’t type some of the characters.
With char-folding, when you hit C-s and search for ", Emacs will also search for a variety of double quotes, from the aforementioned “” to many others like «» and ❝❞. The same goes for the single quote, and for pretty much any other ASCII character.
You could always type any Unicode character by name with C-x 8 RET, and many of them even have their own shortcuts under C-x 8, but not having to type them can be a significant convenience when it comes up. As any Brazilian, I am a daily user of diacritical marks (ó, ã, ê, and the likes), and even though my keyboard can type these characters, I still enjoy the simplicity of not having to.
Finally, you can extend this feature to the
query-replace
command, which is also as easy as setting a variable.Tags: emacs-25, search, init.el, emacs,
New in Emacs 25.1: EWW improvements »
« New in Emacs 25.1: Round quotes in Help buffers
Related Posts
Emacs 25 is out! What are the new features and what were my predictions in emacs-25
Leave the cursor at start of match after isearch in search
Quickly search for occurrences of the symbol at point in search
Content © 2019, All rights reserved. Icons under CC3.0.