UNIX text pagers: more (or less)?

During your work on a system, you’ll often want to page through a document or some output. Aside from the pagers more and less and view, there really are no other ubiquitous options. There are other programs like w3m and pg, but they are not commonly found.

view has a lack of support for input from stdin (such as from a pipe or another command). This rules it out for lots of administration work. It is, however, ubiquitous, as it is part of vi. If you are used to vi, you may want to use view for looking at files (though not for output).

less is, as are many tools, found everywhere as one of the first things added – but almost never installed by default. The reason for this is unclear – other programs such as perl and ruby and tcl are also often found this way (that is, not installed by default but nearly always installed after the fact). If it is added that often, it should be part of the default install, one would think.

However, more is everywhere and is installed by default. The version of more installed on HP-UX appears to be much enhanced over the original more – a fact that is made apparent when you’ve gotten used to HP-UX more and try to use the Linux more. HP-UX more allows you to go back, to search, and other things that are not present in the Linux more.

Perhaps someone should copy the HP-UX more into Linux…. Hmmm…..

A “new” file pager: view

I, like most people I know, adore the file pager less. However, for whatever inconceivable reason, new UNIX systems (Linux doesn’t count here!) virtually never come with less. So… what to do when less is missing?

HP-UX, for one, comes with more and pg. Everything comes with more – but once you’ve used less you’ll never want to use a standard more again. The pager pg really isn’t any better.

Is there a solution? Yes – view.

What is view? The program view is a file pager which is included on virtually all UNIX and Linux systems. The view program is available, for example, in Solaris 9, HP-UX 11i v2, FreeBSD 6.2, Red Hat Linux 9, and more.

If you know vi, then you’ll know view. Why? Because view is actually vi in disguise, acting as a file pager with read-only access to the file.

The biggest drawback to view is that it does not handle stdin; that is, using view as the destination of a pipe gets very messy very fast (i.e., don’t do that!).

Apparently, vim handles this situation much better. Perhaps much better: there are ways to specify the use of vim with less keymappings, and to use view (i.e., vim) for general pager use! There are directions on how to make vim work as a man page viewer complete with syntax highlighting. Here is the quick and dirty instructions (for ksh):

export MANPAGER="col -b | view -c 'set ft=man nomod nolist' -"

For less key bindings, use (for ksh again):

export MANPAGER="col -b | /usr/share/vim/vim61/macros/less.sh -c 'set ft=man nomod nolist' -"

Be sure to use the right macro location for your version of vim. If you check out the original directions, be sure to read all of the comments: there are directions on how to properly configure the environment so reading man pages inside vim will work properly, and so that non-English locales can be handled properly, and more.

Next time you find yourself suffering without less – stop suffering through more and use view instead. You’ll be glad you did.