Vim as a Manpager

9 views
Skip to first unread message

Ajay Jain

unread,
Dec 4, 2008, 8:39:01 AM12/4/08
to vim...@googlegroups.com
Hi,

I am using putty (on Windows) to login to a linux machine.

I wish to read the manpages using Vim. I have added the followig to my
.bashrc:

export PAGER="/bin/sh -c \"unset PAGER;col -b -x | view -c 'set ft=man
nomod nolist' -c 'map q :q<CR>' -c 'map <SPACE> <C-D>' -c 'map b <C-U>'
-c 'nmap K :Man <C-R>=expand(\\\"<cword>\\\")<CR><CR>' -\""

However, I am not able to read the manpages correctly. Some characters
are distorted etc etc. Can somebody share his tested settings, so that I
can read these pages in the best possible way.

Thanks and Regards,
Ajay.

Frans Grotepass

unread,
Dec 4, 2008, 9:04:06 AM12/4/08
to vim...@googlegroups.com
Have you tried <Shift>k in command mode?

It could be what you're looking for.

Erik Hahn

unread,
Dec 4, 2008, 10:42:44 AM12/4/08
to vim...@googlegroups.com

Try changing the NROFF line in /etc/man.conf to this:

NROFF /usr/bin/nroff -Tascii -c -mandoc

-Erik

Thor Andreassen

unread,
Dec 5, 2008, 10:57:32 AM12/5/08
to vim...@googlegroups.com
On Thu, Dec 04, 2008 at 02:39:01PM +0100, Ajay Jain wrote:

[...]

> I wish to read the manpages using Vim.

I recommend you read tip 167:

http://vim.wikia.com/wiki/Using_vim_as_a_man-page_viewer_under_Unix

[...]

--
HTH
Thor

Noah

unread,
Dec 5, 2008, 11:24:22 PM12/5/08
to vim_use
Here is what works for me -- just two steps:

1. Put this near the top of your ~/.vimrc on the remote host.
That's two single quotes ('') which means to reset it to empty
so Vim won't try to call itself if you follow links inside of one
man page to another:

let $PAGER=''

2. Add this to your ~/.bashrc on the remote host
(or add to whatever Bourne family shell rc file you use).
Be sure that you don't have PAGER defined anywhere else:

export PAGER="/bin/sh -c \"unset PAGER;col -b -x | \
vim -R -c 'set ft=man nomod nolist' -c 'map q :q<CR>' \
-c 'map <SPACE> <C-D>' -c 'map b <C-U>' \
-c 'nmap K :Man <C-R>=expand(\\\"<cword>\\\")<CR><CR>' -\""

2 Alternate: If you are a CSH weirdo then this works so-so. Put this
in your
~/.cshrc file. I have not figured out all the stupid csh quoting rules
to make all the mappings work:

setenv PAGER /bin/sh\ -c\ \"unset\ PAGER\;col\ -b\ -x\ \|\ \
vim\ -c\ \'set\ ft=man\ nomod\ nolist\'\ -\"

That makes Vim work as your default pager (what man calls for
paging).
It's pretty much like your regular Vim with a few mapping to make it
a little bit more or less like "more" or "less" pagers.

<SPACE> - scroll down half page
b - scroll up half page
q - quit the Vim pager
K - follow man page links to other man pages.
That's a capital k (shift k).

You might also want to consider using Cygwin+xterm instead of putty.
Xterm has better terminal emulation than PuTTY.

--
Noah Spurrier

Matt Wozniski

unread,
Dec 6, 2008, 4:21:04 AM12/6/08
to vim...@googlegroups.com
On Fri, Dec 5, 2008 at 11:24 PM, Noah wrote:
>
> You might also want to consider using Cygwin+xterm instead of putty.
> Xterm has better terminal emulation than PuTTY.

Xterm certainly has some capabilities that PuTTY doesn't have, but -
in what way does it have "better" terminal emulation? Ie, how is
xterm with TERM=xterm-256color better than PuTTY with
TERM=putty-256color?

~Matt

Noah

unread,
Dec 6, 2008, 9:09:41 AM12/6/08
to vim_use
This is a hard one because I don't have any examples to show.
The ANSI protocol is not trivial. Most terminal emulators do not
implement the full specification and many have quirks and bugs
that can cause the state of the screen to get out of sync with what
the applications thinks is being displayed. Some terminals handle
Unicode and UTF more gracefully than others. The venerable xterm
is not perfect, but it's fast and well tested. It rarely has parsing
problems... From personal experience, I found that PuTTY would get
corrupted more easily than xterm. PuTTY does have a lot of merit.
PuTTY is a small, single-EXE application that requires no
installation.
But when I am forced to use Windows for any amount of time
I end up installing Cygwin anyway, so then there is no reason
not to use xterm.

I'm always looking for a better Unicode terminal that is simple and
fast.
Lately I've been using rxvt-unicode.
--
Noah

Ajay Jain

unread,
Dec 10, 2008, 2:01:40 AM12/10/08
to vim...@googlegroups.com

> I am using putty (on Windows) to login to a linux machine.
> However, I am not able to read the manpages correctly. Some characters
> are distorted etc etc. Can somebody share his tested settings, so that I
> can read these pages in the best possible way.

Here is what works for me -- just two steps:

1. Put this near the top of your ~/.vimrc on the remote host.
That's two single quotes ('') which means to reset it to empty
so Vim won't try to call itself if you follow links inside of one
man page to another:

let $PAGER=''

2. Add this to your ~/.bashrc on the remote host
(or add to whatever Bourne family shell rc file you use).
Be sure that you don't have PAGER defined anywhere else:

export PAGER="/bin/sh -c \"unset PAGER;col -b -x | \
vim -R -c 'set ft=man nomod nolist' -c 'map q :q<CR>' \
-c 'map <SPACE> <C-D>' -c 'map b <C-U>' \
-c 'nmap K :Man <C-R>=expand(\\\"<cword>\\\")<CR><CR>' -\""

After following this there are some unresolved issues:

For example:

1) gcc [-câ-Sâ-E] [-std=standard]: The distorted character should have been a |.

2) WHEN may be âneverâ: The distorted character should have been '.

Can we deal with them and correct them?

Rgs | Ajay.

Reply all
Reply to author
Forward
0 new messages