:h manpager
describes how to use vim as a manpager:
Works on:
- Linux
- Mac OS
- FreeBSD
- Cygwin
- Win 10 under Bash
Untested:
- Amiga OS
- BeOS
- OS/2
For bash,zsh,ksh or dash by adding to the config file (.bashrc,.zshrc, ...)
export MANPAGER="env MAN_PN=1 vim -M +MANPAGER -"
The line above works for me on Linux (Debian 9.2), but the same setting on a Mac (10.11 El Capitan) causes the following error every time I invoke man
:
Error detected while processing function <SNR>57_MANPAGER:
line 16:
E684: list index out of range: 2
E15: Invalid expression: page_sec[2] page_sec[1]
Press ENTER or type command to continue
Question 1: Is this a bug?
Should I file a bug report with vim?
EDIT: This appears to be a bug in the
$VIMRUNTIME/plugin/manpager.vim
plugin. Line 18 reads:let manpage = matchstr( getline(1), '^' . pagesec_pattern )
It can be fixed by replacing
getline(1)
withgetline(nextnonblank(1))
.
Question 2: Is there a workaround?
I've found alternate settings for the MANPAGER
environment variable on /r/vim and this StackExchange that make it work on macOS, but both of them cause navigation via <C-]>
to break and give the folllowing output:
sh: -c: line 0: syntax error near unexpected token `||'
sh: -c: line 0: `(cd '/usr/share/man' && (echo ".ll 12.1i"; echo ".nr LL 12.1i"; /bin/cat '/usr/share/man/man1/vimtutor.1') | /usr/bin/tbl | /usr/bin/groff -Wall -mtty-char -Tascii -mandoc -c | ( || true))'
Error executing formatting or display command.
System command (cd '/usr/share/man' && (echo ".ll 12.1i"; echo ".nr LL 12.1i"; /bin/cat '/usr/share/man/man1/vimtutor.1') | /usr/bin/tbl | /usr/bin/groff -Wall -mtty-char -Tascii -mandoc -c | ( || true)) exited with status 512.
No entry for vimtutor in section 1 of the manual
EDIT: Even with the fix described above, I'm continuing to get this error when navigating between man pages. It looks like it's being caused by the
( || true)
statement in the shell command, but I'm not sure where that shell command is being invoked from.
Does anyone know of a fully working solution?
Running vim 8.0.596
$ vim --version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled May 8 2017 15:44:54)
MacOS X (unix) version
Included patches: 1-596