I'm using vim, cscope and NERDTree and I cannot find how to open NERDTree to be pointing to specific file (one that is an active buffer) but to have root directory equal to directory from which I opened Vim.

Is there a way to do so?


Lets say that I have a file which I'm editing in ./B/C/d.cpp and I opened vim in directory A.

I want A to be NERDTree root, but when I'm toggling NERDTree -> I want B and C directories to be unfolded.

Please help.

1 Answer 1


I believe :NERDTreeFind will do that.

:NERDTreeFind                                                  :NERDTreeFind
    Find the current file in the tree.

    If no tree exists and the current file is under vim's CWD, then init a 
    tree at the CWD and reveal the file. Otherwise init a tree in the current
    file's directory.

    In any case, the current file is revealed and the cursor is placed on it.

You must log in to answer this question.

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