Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep NERDTree open when first select a file #494

Closed
tnguyen14 opened this issue Sep 29, 2015 · 4 comments
Closed

Keep NERDTree open when first select a file #494

tnguyen14 opened this issue Sep 29, 2015 · 4 comments

Comments

@tnguyen14
Copy link

I am not sure if this is the right place to ask this kind of question, but I've tried to do some digging around the web and have not seen anything similar to what I have.

I have set up NERDTree to open whenever I open vim with these commands in my .vimrc from the FAQs:

autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTreeToggle | endif

So NERDTree would open when I first open vim. I would then navigate to the file I want, hit <Enter> to open that file. Upon doing that, the NERDTree window closes. When I do NERDTreeToggle again, the NERDTree window opens, but the position of any expanded directory is lost, i.e. it is reset to the original structure.

If I start expanding them now, and toggle NERDTree again, the positions are remembered from this point.

So my question is whether there's a way to not close the window when I first open the file, and also to remember the position of how the folders are expanded?

@jamischarles
Copy link

I'm trying to fix this as well. For me I have to manually use :NERDTreeFind to resolve it. I'm trying to automate that though.

@scrooloose
Copy link
Collaborator

Hey guys, I am not sure exactly what is happening here, but it sounds as though the first nerdtree is a "window tree" while the second one is a "tab tree". Window trees are local to one window - they appear when you edit a directory. Tab trees are local to the tab, appear on left side and are toggled with NERDTreeToggle.

How are you starting vim? with vim or vim .? If you are using the later then the tree that appears will be a window tree.

To find out, put the cursor on the tree and use echo b:NERDTree._type. This will either be "tab" or "win". What is the output?

@tnguyen14
Copy link
Author

@scrooloose wow you're right. I've been doing vim . (habits from before using vim, such as subl . and atom .. I just realized that I could just do vim and it would open vim with the current directory as well. And it behaves exactly as I wanted.

Thanks for looking into this and discovering the issue. Should I close this issue now? Is it worthwhile to be put in some documentation?

@scrooloose
Copy link
Collaborator

Done :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants