Alex Rivera | Logout

Does less have an equivalent to vim's scrolloff?

Asked 2011-06-16T17:54:19.917
12

I have scrolloff set to 4 in vim. This means that when I scroll up or down, there are 4 lines between the line I'm on and the bottom or top of the screen.

When I use less, usually to view a manpage, I use / to search for text. If I'm looking for a command line option that does something and I search for the term 'something' usually 'something' shows up in the paragraph explaining a command, and the command line switch is a line or two above that, so I have to scroll up to see it. Any ideas for how to make less act more like vim in this one case?

Edit
Report

1 Answer

1

Not sure if you can make less do this by itself, but did you know you can use Vim in place of less as your pager? There's a macro in the Vim installation macros/ directory called less.vim. Copy it to your own .vim/macros directory to enable, then alias less in your .bashrc (or whatever your shell)

# example:
alias less='/usr/share/vim/7.x/macro/less.sh'

EDIT Unfortunately I just tried this myself and it ignores the scrolloff by default. You could modify the less.sh to set scrolloff=3 at launch.

answered 2011-06-16T17:59:38.353

Your Answer