Search code examples
vimterminalless-unix

Make regular text file paged in terminal with less or something like that


I'm looking for the way to be able to edit text file with any text editor and read it split into pages in terminal with tool like less. So is there a way to put an special symbol or directive to tell less continue with following text on next page?


Solution

  • The obvious (standard) approach would be to put form-feed (controlL) characters in the file (see What are carriage return, linefeed, and form feed?).

    However, the less pager (which has become prevalent) ignores those (except to highlight them).

    Interestingly, the more program is documented as honoring form-feeds by default (see for example Is there a pager that stops on form feeds?),

    • but (disregarding the manpage) that does not apply to Debian and Fedora (both using a package named "util-linux", perhaps with the intention of imitating less), and
    • in OSX a similar "improvement" uses identical binaries for more and less. MacPorts does not list a more port.
    • FreeBSD also equates "more" and "less".

    Since POSIX's description of more does not mention treatment of form-feed, you cannot rely upon finding the feature in whatever happens to be called "more".