3

To use Vim as a pager for man I have

export MANPAGER="/usr/share/vim/vim73/macros/manpager.sh"

in my profile. Now man pages look very good with colors and stuff. However, when trying man ascii as a way of looking at the ASCII table, I notice that the table is mis-aligned as in the screenshot below:

Messed up ASCII table

This problem doesn't happen to the default pager. When I set export MANPAGER="view -" the table is also correct, so something must be wrong with the manpager.sh script:

#!/bin/sh
sed -e 's/\x1B\[[[:digit:]]\+m//g' | col -b | \
vim \
    -c 'let no_plugin_maps = 1' \
    -c 'set nolist nomod ft=man' \
    -c 'let g:showmarks_enable=0' \
    -c 'runtime! macros/less.vim' -

How can I fix this?

1
  • It works for me (Vim 7.1pl314 on Debian lenny or 7.2pl330 on Ubuntu 10.04, C or en_US or en_US.UTF-8 locale, in xterm). What are your locale settings? In what terminal are you running this, and do other terminals make a difference? What is your version of Vim, what options was it compiled with? Does disabling your .vimrc with vim -u /dev/null make a difference? Feb 19 '11 at 15:15
5

When I try with the following script things are normal:

#!/bin/sh
sed -e 's/\x1B\[[[:digit:]]\+m//g' | \
vim \
    -c 'let no_plugin_maps = 1' \
    -c 'set nolist nomod ft=man' \
    -c 'let g:showmarks_enable=0' \
    -c 'runtime! macros/less.vim' -

I'm not sure what role col plays in the sequence, but it is certainly messing up the spaces. Until somebody gives a better solution, this will be my fix.

Edit: so col was the problem because it "replaces white-space characters with tabs where possible". To fix this tell col to use spaces instead of tabs with the -x option. The final config is as follow (with credit to Gilles).

#!/bin/sh
sed -e 's/\x1B\[[[:digit:]]\+m//g' | col -bx | \
vim \
    -c 'let no_plugin_maps = 1' \
    -c 'set nolist nomod ft=man' \
    -c 'let g:showmarks_enable=0' \
    -c 'runtime! macros/less.vim' -
5
  • I wrote my comment on your question before I saw your answer. So maybe the version or configuration of col is the culprit. col replaces spaces with tabs, so it's easy to see why it would influence column alignment. I don't know what could have gone wrong though. Feb 19 '11 at 15:16
  • @Gilles Where is the configuration file for col? I looked in /etc/ but no file name starts with "col".
    – phunehehe
    Feb 19 '11 at 15:25
  • Now that I think of it, there shouldn't be any configuration for col (neither compile-time nor run-time). col was standardized in earlier versions of Single Unix. Does col -bx solve the problem? What about col -bp? Feb 19 '11 at 15:30
  • @Gilles col -bx works (col -bp does not)! Do you want to make that another answer?
    – phunehehe
    Feb 19 '11 at 15:37
  • You thought the problem might be col, so just edit your answer. Feb 19 '11 at 16:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.