I have a file with really long lines that I am trying to view in less. If I am near the top of the file, I can arrow right or use -S (to disable line wrapping) and then press down arrow or e and it will move down by one line. But if I am near the end of the file, this doesn't work. It just says END.

I noticed that there is an ESC-SPACE shortcut to move by a page even if near the end of the file, but ESC-e doesn't work. So I have to use -S ESC-SPACE and then UP ARROW many times (being careful not to go too far!) to move down a line.

I also tried searching for a newline with /\n but that just searched for the letter n (less --version says it is compiled with POSIX regular expressions, maybe that is the problem).

Is there a simpler way to move down by a single line in less. I really would like for RIGHT ARROW DOWN ARROW to "just work" even if it is near the end of the file.

  • Sometimes I just use ´mcview´ which is a part of midnight commander as a workaround . You can wrap/unwrap, switch to hex view, etc. Maybe that works for you.
    – Michael D.
    Dec 30 '16 at 20:04

less seems to support pressing J (i.e. shift+j) to always scroll one line, even when at the end of the file. Conversely, K will always scroll the other way, even when at the top of the file.

I'm unable to determine out how I found this the first time! If anyone has any pointers, would be good to see what other commands exist.

  • I found this in the less manpage: J Like j, but continues to scroll beyond the end of the file.. It isn't mentioned in the less online help (h). I guess that help isn't exhaustive. It seems that both K and Y do this for the beginning of the file.
    – asmeurer
    Jan 10 '17 at 22:01

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.