Search This Blog

Monday, February 19, 2007

Using vim as a man page reader

vim, gvim can be used to read man pages. To accomplish this add the following lines to ~/.bashrc file.
# Use vim as a manpage reader
function vman {
/usr/bin/man $* | /usr/bin/col -bp | /usr/bin/iconv -c | \
/usr/bin/view -c "set ft=man nomod nolist so=999 ts=8 wrap\
titlestring=man\ $1" -
}
# Use gvim as a manpage reader
function wman {
/usr/bin/man $* | /usr/bin/col -bp | /usr/bin/iconv -c | \
/usr/bin/gview -c "set ft=man nomod nolist so=999 ts=8 wrap\
titlestring=man\ $1" -
}
After this man pages can be read by using vman or wman. Sample commands look like
guest@kusumanchi:~$ vman rsync
guest@kusumanchi:~$ wman rsync
Tested this on Debian Etch, running vim 7.0.122, gvim 7.0.122, man 2.4.3, iconv 2.3.6.

Advantages of using vim as a man page reader
  1. 'marks' can be used to navigate the man pages which can sometimes be quite large. Other pagers such as 'less', 'more' do not have this feature.

  2. vim's search commands, navigation commands etc., can be used. No need to learn another software or another set of shortcuts.

  3. ":syn on" gives beautiful colors while reading the man page

  4. Let's say while reading the man page of ssh, you encounter ssh_config(5). Now to read the man page of ssh_config(5), simply place the cursor on that word and do ctrl-]. This will place you at the man page of ssh_config(5).

Sources:
  1. http://tech.groups.yahoo.com/group/vim/message/76376
  2. http://vim.sourceforge.net/tips/tip.php?tip_id=167

No comments:

Followers