export MANPAGER='bash -c "vim -MRn -c \"set ft=man nomod nolist nospell nonu\" \
-c \"nm q :qa!<CR>\" -c \"nm <end> G\" -c \"nm <home> gg\"</dev/tty <(col -b)"'
(if pasting that in a terminal make sure to \ the ! in the second line)
The above works fine for man-db too, except when using Ctrl-[
to drill down into sub man pages. In that case man-db will
run the output through $MANPAGER again, even though the
output is not a tty. That would cause various vim errors
and hangups. I was able to work around this in my ~/.vimrc with:
augroup man
au!
"Ensure vim is not recursively invoked (man-db does this)
"when doing ctrl-[ on a man page reference
au FileType man let $MANPAGER=""
augroup END
So rather than doing that, the patch below
just does the same in man.vim
cheers,
Pádraig.
--- /usr/share/vim/vim73/ftplugin/man.vim 2010-11-29 10:00:14.392636934 +0000
+++ man.vim 2010-11-29 10:00:07.233636869 +0000
@@ -15,6 +15,10 @@
endif
let b:did_ftplugin = 1
+ "Ensure vim is not recursively invoked (man-db does this)
+ "when doing ctrl-[ on a man page reference
+ let $MANPAGER=""
+
" allow dot and dash in manual page name.
setlocal iskeyword+=\.,-
> Fedora 14 switched to man-db for handling man pages.
> Ubuntu has been using it for ages.
> On older versions of Fedora I was able to just
> add this to my .bashrc to have full man page
> functionality, (with drill down) using vim
>
> export MANPAGER='bash -c "vim -MRn -c \"set ft=man nomod nolist nospell nonu\" \
> -c \"nm q :qa!<CR>\" -c \"nm <end> G\" -c \"nm <home> gg\"</dev/tty <(col -b)"'
>
> (if pasting that in a terminal make sure to \ the ! in the second line)
>
> The above works fine for man-db too, except when using Ctrl-[
> to drill down into sub man pages. In that case man-db will
> run the output through $MANPAGER again, even though the
> output is not a tty. That would cause various vim errors
> and hangups. I was able to work around this in my ~/.vimrc with:
>
> augroup man
> au!
> "Ensure vim is not recursively invoked (man-db does this)
> "when doing ctrl-[ on a man page reference
> au FileType man let $MANPAGER=""
> augroup END
>
> So rather than doing that, the patch below
> just does the same in man.vim
Thanks, I'll include it.
--
It is too bad that the speed of light hasn't kept pace with the
changes in CPU speed and network bandwidth. -- <wie...@porcupine.org>
/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Shouldn't that be ctrl-] ?
I have no objection to this patch. so, Ack.
BTW, I'm not sure man.vim should include such lines at all. Original
reporter already found a workaround for his problem. And his patch
caused side-effect for others.
Regards,
namsh
Thanks. Since SungHyun Nam agreed I'll include this.
--
MORTICIAN: What?
CUSTOMER: Nothing -- here's your nine pence.
DEAD PERSON: I'm not dead!
MORTICIAN: Here -- he says he's not dead!
CUSTOMER: Yes, he is.
DEAD PERSON: I'm not!
The Quest for the Holy Grail (Monty Python)
I've also experienced man.vim crashing when $MANPAGER had been already
defined to `col -b | vim -R -' in .bashrc. I took a look at the man.vim
file and came up with the following idea.
Instead of asking if $MANPAGER was defined, why not define it
temporarily for the call. It's possible to do this via
let tmp = tempname()
let $MANWIDTH = &tw ? &tw : 80
let manpager = shellescape('less -s') " Fixes problems when user has defined $MANPAGER
silent execute "!MANPAGER=".manpager." /usr/bin/man ".args."| col -b > ".tmp
silent execute "pedit ".tmp
See the attachment for the complete reimplementation of GetPage(). I
also wanted to fix a couple of subtle shortcomings of the original script.
In my opinion, viewing man pages should mimic reading help pages which
is already reflected nicely in the mappings <C-]> and <C-t>. However, it
would also be nice to be able to double click the topics as one can do
in help files.
Man pages should also be closed when the last writable buffer is closed
in the current tab page, as is the case with help files. Now the user is
potentially left with two windows to the same shell script. The first
was used to spawn a man page via <Leader>K for example and the second
appeared unintentionally when the user rewinded man pages one time too
many.
Finally, all man pages shouldn't be only 'readonly' but also
'nomodifiable'.
All of these aspects are taken care of in the script you'll find in the
attachment. I post it to your consideration.
On Mon, 25 Jul 2011, Bram Moolenaar wrote:
>
> Mike Mcewan wrote:
>
>> It's been a while since I reported a problem with the patch here and no
>> further comment has been made. I guess the majority of users out there are
>> probably using one of the pre-packaged versions of vim 7.3 and so this
>> problem hasn't come down the pipeline to hit them yet. I have seen one other
>> reference to the problem whilst browsing the web:
>> http://crumbtrail.chesmart.in/
>>
>> I still don't think the original patch was the right solution here, but
>> until someone comes up with a better solution, I wonder if the the following
>> patch could be applied?
>>
>> --- a/ftplugin/man.vim 2011-07-22 19:55:14.000000000 +0100
>> +++ b/ftplugin/man.vim 2011-07-24 17:55:49.000000000 +0100
>> @@ -17,7 +17,9 @@
>>
>> " Ensure Vim is not recursively invoked (man-db does this)
>> " when doing ctrl-[ on a man page reference.
>> - let $MANPAGER = ""
>> + if exists("$MANPAGER")
>> + let $MANPAGER = ""
>> + endif
>>
>> " allow dot and dash in manual page name.
>> setlocal iskeyword+=\.,-
--
Elias Toivanen <elias.t...@helsinki.fi>
Using "!env MANPAGER=...." is better as not all shells support declaring
environment variables to use for a command invocation like that.
--
James
GPG Key: 1024D/61326D40 2003-09-02 James Vega <jame...@jamessan.com>