help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Use Vertico + consult to do the search for an exact word.


From: Tassilo Horn
Subject: Re: Use Vertico + consult to do the search for an exact word.
Date: Thu, 01 Jun 2023 08:50:28 +0200
User-agent: mu4e 1.11.6; emacs 30.0.50

Hongyi Zhao <hongyi.zhao@gmail.com> writes:

> In Emacs, I use Vertico + consult to do the in-buffer and minibuffer
> search and bind bound the command `consult-line' to M-s l.
>
> What puzzles me is that this cannot let me search for an exact word.
> For example, if I want to sear all the occurrences of the word `id',
> the result obtained is shown in the attached file, which obviously is
> not what I want.
>
> How to achieve my goal based on Vertico + consult for utilizing the
> more intuitive minibuffer display?

I don't use consult myself but I guess the search string is a regular
expression.  So when you want to search for an exact word, use \bid\b to
find all occurrences of the word id.

See (info "(elisp) Regexp Backslash") for details:

--8<---------------cut here---------------start------------->8---
‘\b’
     matches the empty string, but only at the beginning or end of a
     word.  Thus, ‘\bfoo\b’ matches any occurrence of ‘foo’ as a
     separate word.  ‘\bballs?\b’ matches ‘ball’ or ‘balls’ as a
     separate word.

     ‘\b’ matches at the beginning or end of the buffer (or string)
     regardless of what text appears next to it.
--8<---------------cut here---------------end--------------->8---

HTH,
Tassilo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]