(已解决)求教consult-imenu 按word过滤类名的方法

如果我在一个文件里头有多个类名类似这个 Mesh, Mesh2D, Mesh3D, 那我用consult-imenu搜索的时候,如何精确的只搜索Mesh,而不出现其它的选项呢?

已经解决,在后面加 \b

\b 是啥意思?

就是你先输命令consult-imenu,然后这时候你不是输入字符搜索吗? 然后输入 Mesh\b 这样就可以过滤掉 Mesh2D, Mesh3D

看起来像是正则表达式的元字符

\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 regardless of what text appears next to it.

1 个赞