“less"中是否有词边界的快捷方式? [英] Is there a shortcut for word boundary in `less`?
问题描述
这是我使用的较少:
less 458 (POSIX regular expressions)
Copyright (C) 1984-2012 Mark Nudelman
在 Vim 中它是 \<
和 \>
,在大多数其他正则表达式中它是 \b
.
In Vim it is \<
and \>
, in most other regex it is \b
.
推荐答案
你的 less
版本是用 posix 正则表达式构建的,就像:
Your version of less
was built with posix regular expressions, as if:
wget http://ftp.gnu.org/gnu/less/less-451.tar.gz
tar zxf less-451.tar.gz
cd less-451
./configure --with-regex=posix
make
然而,显然 \<
是否有效的原因并不取决于此:
However, apparently the cause of whether \<
works or not does NOT depend on this:
- 在 Debian/Linux 中,
\<
即使您使用上述命令和 posix regex 构建也能正常工作 - 在 Mac OS X 中,除了
pcre
,我尝试了--with-regex
的所有可能值,而\<
没有与他们中的任何一个一起工作.如果我使用pcre
构建,则\b
可以工作,而不是\<
.
- In Debian/Linux,
\<
will work fine even if you build with the above commands, with posix regex - In Mac OS X, I tried all possible values of
--with-regex
exceptpcre
, and\<
doesn't work with any of them. If I build withpcre
, then\b
works, instead of\<
.
总而言之,我不知道如何让它与 \<
一起工作.但是您可以使用 pcre
构建自己,然后它应该可以与 \b
一起使用.如果您不是系统管理员,您可能希望使用 --prefix
安装在您的主目录下,例如 --prefix=$HOME/opt
.在 make
步骤之后,确认它与 ./less/path/to/some/file
一起工作.如果看起来不错,则使用 make install
完成.
To conclude, I don't know how to make it work with \<
. But you can build yourself with pcre
and then it should work with \b
. If you are not a sysadmin, you probably want to use a --prefix
to install under your home directory, for example --prefix=$HOME/opt
. After the make
step, confirm it works with ./less /path/to/some/file
. If looks good, then finish with make install
.
这篇关于“less"中是否有词边界的快捷方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!