8

Is it possible to scroll past the bottom in less?

Ideally, I'd like to be able to see the last line of the file I am viewing at the top of my terminal window (the rest of the screen may be filled with tildes (~), which mean empty line/nothing to see here in less).

12

Yes, using J (as in ShiftJ). So you can go to the end of the file with G, then scroll down past the end with J until the last line of the file is at the top of the screen (less won’t let you scroll any further).

K and Y do the same at the top of the file, scrolling up past the beginning until the first line is at the bottom of the screen.

As David Ongaro points out, you can use repeat specifiers to avoid having to press J multiple times: G99J will thus scoll down until the last line is at the top of the screen (unless your terminal has a very large number of rows).

  • 1
    Yes! They used the word beyond instead of bottom: that's why I could not find it. Also, I thought that there should be a flag for it. Nevertheless, this is the correct answer. Thanks! I'll accept it ~soon. :) – Mateusz Piotrowski Mar 10 '18 at 19:14
  • Seems with 100J one can avoid hitting J repeatedly. – David Ongaro Mar 11 '18 at 6:03
2

The -c option also creates "scroll past EOF" behavior in some circumstances.

Without -c, when you are near the end of file (the remaining part after the part you currently see is less than a screen height), the space scrolls down just enough to put the last line of the file on the last line of the screen. space can be equivalent to j if there's only one more line to show.

With -c, as long as you aren't at EOF already, space always scrolls forward a full screen height. The top line on the screen after space will be the line after the one that was at the bottom before the space. This can leave some portion of the screen unused, and it is filled with the ~ markers.

In -c mode, to make the last line the only visible line, G K space is all you need.

...unless the last line in the file is wider than the screen width, in which case you need to repeat the K.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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