Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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