Shinigami
Shinigami

Reputation: 2213

How to open a project directory in a new MacVim window with NERDTree

If I want to open, say, a Rails app in MacVim with NERDTree, I simply do $ mvim . from that directory. A new window open with the NERDTree navigator on the left and a buffer on the right.

Now let's say I want to do the same thing, but I already have a MacVim window open. From that window, I want to do exactly what I did above, but without needing to go back to the command line.

I do Cmd-N to open a new window, then I type: :e ~/path/to/new/project. But the NERDTree navigator I get here doesn't work correctly. It's as if it's not aware of the buffer to its right. It doesn't expand or collapse directories and pressing enter on any of the files will open it in the same window as the navigator.

I'm new to all this, so hopefully my terminology and description make some sense :)

Upvotes: 1

Views: 2488

Answers (2)

MatanRubin
MatanRubin

Reputation: 1085

From wherever you are, you can issue :NERDTree ~/path/to/new/project and NERDTree will open up with ~/path/to/new/project as the root. I tried it out and it behaves as expected.

Upvotes: 1

romainl
romainl

Reputation: 196456

Assuming the mvim script bundled with MacVim is in your $PATH you can simply do:

:!mvim ~/path/to/new/project

Upvotes: 1

Related Questions