Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 1 down vote accepted
let $MANPATH = substitute(system("manpath"), "\n", "", "")

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

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .