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.

link|improve this question
feedback

1 Answer

up vote 0 down vote accepted
let $MANPATH = substitute(system("manpath"), "\n", "", "")

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

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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