5

I want to be able to search entire page instead of just below (/) or above (?). Is this possible?

As of now I have to navigate to top of a page and perform forward (/) search, I would rather prefer eliminating the first step. And sometimes I need to search around the middle of a page so after the first step I would have to press PageDn several times.

I'm open to try less alternatives such as moor.

2

1 Answer 1

11

Since less moves to the next search result, it has to be told what direction to move in — that’s why there’s a forward search and a backward search. It is however possible to customise the search behaviour in a variety of ways that might help you get closer to what you’re after:

  • You can highlight search results without moving, by typing CtrlK at the start of the search. /CtrlKfooEnter will highlight “foo” without moving. The highlighting is preserved as you move around the document, so if you get to the middle of a document, decide you want to see matches for a given search string around the middle, you can highlight the matches without moving and see the results.

  • You can wrap the search around, by typing CtrlW at the start of the search.

  • You can filter, by typing & instead of /. This will only show lines matching the given search pattern, and you can add more patterns to filter by with & again. & with an empty pattern cancels the filtering.

Search options can be set by default with --search-options, for example --search-options=K to search without moving, or --search-options=W to wrap searches.

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.