Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

There is one little thing annoying me in man pages. When I search for text using '/' command the line where the text is found is positioned at the top of the screen. I find it inconvenient because when I search for text I want to see it in the context which also includes the a couple of lines before the found text.

Is there a way to tell the man pager not to scroll the screen all the way to the top during search?


share|improve this question
up vote 5 down vote accepted

If you are using less as your man pager, you can set the environment variable to include a jump line number:

export LESS=-j4

for example (or add "j4" or a number you choose to the existing value of the variable). Here is mine:

export LESS=-iMFXRj4a

You can add or change that in your ~/.bashrc file so it's set each time you start a session.

share|improve this answer
Awesome! Thanks. – jackhab Mar 3 '10 at 12:12
I needed to export the LESS variable before it worked. Example: export LESS=-j4 – gregh Jun 27 '11 at 20:48
@gregh: Thanks for the reminder. I added the export in my answer. – Dennis Williamson Jun 28 '11 at 2:05

Per default man uses the content of the environment variable $PAGER to display man pages (when it's not set, it uses /usr/bin/pager, which is usually a symbolic link to less).

See if you can find a text display program that has the behaviour you want (perhaps as an option) and put it in $PAGER.

share|improve this answer

As suggested by Michael Borgwardt you can use a different "pager". For example I use vim for visualizing man pages by setting the following line in .bashrc:

export PAGER="/bin/sh -c \"col -b -x | view -c 'set ft=man nomodifiable' -c 'map q :q<CR>' -\""

In this way you will benefit from a more intelligent positioning of the highlighted search string and you will benefit from syntax highlighting (colored man pages).

If you still don't like how the searched string is placed you can give a cursor offset using:

share|improve this answer
The scrolloff option can also be useful for keeping context visible in Vim (around the cursor, not just after searches). – Chris Johnsen Jun 28 '11 at 3:14
Immediately into my .vimrc! Thanks. – mrucci Jun 28 '11 at 16:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.