It is not possible to match across line boundaries, because the search function in less
operates on a single newline-delimited line at a time. This is the case regardless of the system regex implementation (GNU, POSIX, PCRE, etc.).
Please note that I couldn't find an official source repository for the mainline development of less
, but for purposes of code review here, the links that follow are from the FreeBSD contrib tree.
See search.c:search_range() for the implementation of the search operation. The loop therein calls line.c:forw_raw_line() to retrieve the next newline-delimited block of content. That block is passed to match.c:match_pattern() where the search pattern (regular expression) is executed.
To match across multiple lines, you'll need to use a different tool. One option is to drop into your editor and use its search capabilities as suggested by others. You can invoke the editor by pressing v
in less
.
Which Linux distribution, and do you have defined the environment variable "LESS" ? – harrymc – 2015-02-23T12:59:43.807
@harrymc How would that help with multiline search? – sashoalm – 2015-02-25T18:54:55.130
Gathering information. – harrymc – 2015-02-25T19:29:13.320
I fear the answer for less must be no, but if you are looking for other ways to search this has been discussed here, pcregrep looks the easiest solution.
– gogoud – 2015-02-25T23:05:38.1372This is not possible, based on a review of the source code for
less
(search.c:search_range()
). The search/match operation is performed on a single newline-delimited line at a time, so you cannot match across line boundaries. Seeline.c:forw_raw_line()
for the implementation of "readline" as called bysearch_range
. – zackse – 2015-02-26T05:50:59.333Have you tried
\n+
for 1 or more newlines? – Brock Hensley – 2014-01-17T01:45:36.793