Using vim as a syntax-highlighting pager

If you want to use Vim's syntax highlighting in a pager, here's how. Since version 6, Vim comes with a script $VIMRUNTIME/macros/less.sh, and this gives syntax highlighting in a pager. See :help less.

The original tip (below) was for a "more"-style pager. It is kept here because it explains the principles nicely.

First, create a vimrc like the following – I called mine ~/.vimrc.more

" No compatibility – necessary for mappings to work.
set nocompatible
" Status line
set laststatus=0
set cmdheight=1
set nomodifiable " Only in version 6.0
set readonly
" My xterms have a navy-blue background, so I need this line too.
set background=dark
" Turn syntax on
syntax enable
" No menu bar and tool bar
set guioptions=aiMr
" Key bindings.
nmap b <C-B><C-G>
nmap q :q!<CR>
nmap <Up> <C-Y>
nmap <Down> <C-E>
" To type the following line, type *two* C-V's followed by two spaces. This
" is how you map the spacebar.
nmap ^V <C-F><C-G>

Then, to use this .vimrc, add an alias. If you're using tcsh, the syntax will
be something like:

alias vmore "vim -u ~/.vimrc.more -"

Then you can type program | vmore to view program's output in this "pager". Spacebar will move down, 'b' will move back up, and 'q' quits. You can add mappings for other keys if you want to, also.