From: Tassilo Horn <tsdh@gnu.org>
To: Hongyi Zhao <hongyi.zhao@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Use Vertico + consult to do the search for an exact word.
Date: Thu, 01 Jun 2023 08:50:28 +0200 [thread overview]
Message-ID: <87zg5jsmez.fsf@gnu.org> (raw)
In-Reply-To: <CAGP6POKa1LnDSD4iPgagfbJH2k5He7ijwk2oxRa_4KsLNMUC_g@mail.gmail.com>
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
next prev parent reply other threads:[~2023-06-01 6:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-31 23:27 Use Vertico + consult to do the search for an exact word Hongyi Zhao
2023-06-01 6:50 ` Tassilo Horn [this message]
2023-06-01 7:36 ` Hongyi Zhao
2023-06-01 9:47 ` Tassilo Horn
2023-06-01 9:59 ` Hongyi Zhao
2023-06-01 18:45 ` Tassilo Horn
2023-06-02 1:53 ` Hongyi Zhao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zg5jsmez.fsf@gnu.org \
--to=tsdh@gnu.org \
--cc=help-gnu-emacs@gnu.org \
--cc=hongyi.zhao@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).