Reputation: 3574
I often search within less
, but it puts the search result to the very top of the screen, which makes reading man pages difficult, since I'm searching for a word, but I really want to see the flag connected to that description, which might be a few lines up.
Is there a way to show more lines at the top of the screen, so that the cursor is something like 5-10 lines below the top of the screen? Something like vim
's scrolloff
option.
Upvotes: 3
Views: 631
Reputation: 839
To show more lines of context before the search result, i.e. to place the search result a few lines down from the top of the screen instead of the top line, use:
less -jX
where X
is the number of lines below the top of the screen where you want your results to end up.
If you usually prefer this style of search results, and want less to use it all the time (for example in man
), put the option in the $LESS
environment variable. For example, to always place the search result 5 lines down, using bash, that will be:
export LESS=-j5
You can of course add any other options to less
in the $LESS
environment variable too if you like.
Upvotes: 1
Reputation: 46
Sounds like you want the -j option. For example, less -j5
would put a search result on line 5.
For man
you'll need to set the PAGER
environment variable to include the -j
.
Upvotes: 3