Telling `less` where to break pages

0

Is there some way to tell less where to break pages?

I was hoping that ^L (form feed / page break) would do it, but found it doesn't. I tried the following:

The first page.
It is three lines
long.
^L
The second page.
Two lines only.
^L
The third page is short.
...

I'd like less to start showing line 1 at the top of the terminal, and after one key press line 5 should be at the top of the terminal. After another keypress it should be line 8.

As far as I can see in the help I can jump a line or a window (or to a specific line).

(If less can't do it, is there a pager that can?)

Magnus

Posted 2017-10-06T09:13:18.027

Reputation: 2 376

Answers

1

From less help:

                     MOVING

 e  ^E  j  ^N  CR  *  Forward  one line   (or N lines).
 y  ^Y  k  ^K  ^P  *  Backward one line   (or N lines).
 f  ^F  ^V  SPACE  *  Forward  one window (or N lines).
 b  ^B  ESC-v      *  Backward one window (or N lines).
 z                 *  Forward  one window (and set window to N).
 w                 *  Backward one window (and set window to N).
 ESC-SPACE         *  Forward  one window, but don't stop at end-of-file.
 d  ^D             *  Forward  one half-window (and set half-window to N).
 u  ^U             *  Backward one half-window (and set half-window to N).
 ESC-)  RightArrow *  Left  one half screen width (or N positions).
 ESC-(  LeftArrow  *  Right one half screen width (or N positions).

As a workaround you can use text editor (like vim to jump to desired line or whatever) in less by pressing v.

atype

Posted 2017-10-06T09:13:18.027

Reputation: 668

I get the feeling that one of us doesn't understand the other. I've changed the question slightly to hopefully clarify what I mean. – Magnus – 2017-10-06T13:43:47.750

I still can't understand, you want pager to jump an arbitrary number of lines? – atype – 2017-10-06T19:13:43.880

Far from arbitrary, I want it to jump based on form feed found in the text file. – Magnus – 2017-10-08T06:13:46.453

1

Emacs has functions with default keybindings for supporting movement between pages separated by ^L in files. Also the ability to narrow a buffer to only show the current page.

See https://www.emacswiki.org/emacs/PageBreaks

pelle

Posted 2017-10-06T09:13:18.027

Reputation: 123

Piping into Emacs is just slightly heavyweight... That is the sort of thing I'm looking for though. I wonder if there's a module for vim that does the same thing. – Magnus – 2017-10-08T06:16:47.343