Getting man path through Vim

1

So, I've set up Vim as my default man viewer. I also have NERDTree starting up automatically - but I could really do without NERDTree showing the location the man pages every time I check man.

I've tried setting up the following in my .vimrc:

if (match(expand("%:p:h"),???) == -1)
    " load NERDTree here
endif

But I'm not really sure what to match the path against. $MANPATH would be the obvious choice, however echo $MANPATH doesn't print anything out in terminal. Running manpath does produce /usr/local/man:/usr/local/share/man:/usr/share/man, but I have no idea how to include that in my vimrc. Of course I could just paste the paths as a string, but that would be cheating.

Basically, what I'm looking for is either:

  • a way to set the $MANPATH variable so that it points to the folders listed by manpath
  • any other way to get the paths in Vim

EDIT: A post-acceptance note in case anyone wants to try that script - match needs to be replaced with matchstr.

Andrey

Posted 2012-01-20T11:26:46.630

Reputation: 167

Answers

1

let $MANPATH = substitute(system("manpath"), "\n", "", "")

The substitute() function removes the trailing newline that the output of system() includes.

garyjohn

Posted 2012-01-20T11:26:46.630

Reputation: 29 085