在 EOF 环绕式搜索更少

viu*_*ser 10 less

是否可以为搜索启用“环绕”功能?这意味着:如果已找到最后一次出现的模式,按n将在文件开头再次开始搜索(因此您不必按g,然后按n)。

Tho*_*key 6

可能不是:手册页less没有提到换行,搜索功能的描述也没有暗示它是可能的。

  • `ggn` 很容易输入,基本上,返回顶部,下一个...... (2认同)

Arm*_*ius 5

是的,自发布v568以来就有可能。

由于这个补丁(完全披露:我写的),搜索修饰符^W在当前文件中启用环绕搜索。在搜索提示下按 CTRL-W 使用它。从联机帮助页

       /pattern
              (...)

              ^W     WRAP around the current file.  That  is,  if  the  search
                     reaches  the  end  of  the current file without finding a
                     match, the search continues from the first  line  of  the
                     current file up to the line where it started.
Run Code Online (Sandbox Code Playgroud)

使其成为默认行为的一种方法是通过配置文件中的命令部分(可能位于~/.lesskey,请参阅man lesskey有关详细信息):

#command
/ forw-search ^W
? back-search ^W
Run Code Online (Sandbox Code Playgroud)

  • 37年后,我们进行了全方位搜索……仍然不敢相信! (2认同)