abstract
| - To use Vim as a man-page viewer involves setting an environment variable and adding a line to your .vimrc file. Add the following line to your vimrc: let $PAGER='' You need to do this to clear the PAGER environment variable inside of Vim. This is to handle the case where you start Vim normally and want to use Vim's "Man" function. bash, ksh, and Bourne variants add to .bashrc, .kshrc, etc.: export PAGER="/bin/sh -c \"unset PAGER;col -b -x | \ vim -R -c 'set ft=man nomod nolist' -c 'map q :q' \ -c 'map ' -c 'map b ' \ -c 'nmap K :Man =expand(\\\"\\\")' -\"" csh, tcsh, and C-shell variants add to .cshrc: setenv PAGER /bin/sh\ -c\ \"unset\ PAGER\;col\ -b\ -x\ \|\ vim\ -c\ \'set\ ft=man\ nomod\ nolist\'\ -\" fish add to .config/functions/config.fish set -x PAGER "/bin/sh -c \"unset PAGER;col -b -x | \ vim -R -c 'set ft=man nomod nolist' -c 'map q :q' \ -c 'map ' -c 'map b ' \ -c 'nmap K :Man =expand(\\\"\\\")' -\"" The man pages will then be displayed with Vim called as "view" and will use the syntax highlighting. I myself use some additional highlighting which is enabled by putting the following file into <.vim/after/syntax/man.vim>. I usually use the astronaut colorscheme; those who use bright backgrounds may find the colors selected for manSubSectionStart and manSubSection something they'll want to change: " DrChip's additional man.vim stuff syn match manSectionHeading "^\s\+[0-9]\+\.[0-9.]*\s\+[A-Z].*$" contains=manSectionNumber syn match manSectionNumber "^\s\+[0-9]\+\.[0-9]*" contained syn region manDQString start='[^a-zA-Z"]"[^", )]'lc=1 end='"' contains=manSQString syn region manSQString start="[ ]'[^', )]"lc=1 end="'" syn region manSQString start="^'[^', )]"lc=1 end="'" syn region manBQString start="[^a-zA-Z`]`[^`, )]"lc=1 end="[`']" syn region manBQSQString start="``[^),']" end="''" syn match manBulletZone transparent "^\s\+o\s" contains=manBullet syn case match syn keyword manBullet contained o syn match manBullet contained "\[+*]" syn match manSubSectionStart "^\*" skipwhite nextgroup=manSubSection syn match manSubSection ".*$" contained hi link manSectionNumber Number hi link manDQString String hi link manSQString String hi link manBQString String hi link manBQSQString String hi link manBullet Special hi manSubSectionStart term=NONE cterm=NONE gui=NONE ctermfg=black ctermbg=black guifg=navyblue guibg=navyblue hi manSubSection term=underline cterm=underline gui=underline ctermfg=green guifg=green set ts=8
|