0

I have following in my ~/.vimrc to make sure that nerdtree opens for every tab:

autocmd VimEnter * NERDTree

I also have this in the ~/.vimrc to make sure that every new buffer opens in its own tab:

au BufAdd,BufNewFile * nested tab sball

At the moment, I'm trying to learn Go programming on vim and have installed vim-go plugin. What happens is that if I hit Ctrl+] to open the definition for identifier under the cursor, vim does open it in a new tab but nerdtree disappears from all tabs.

If I hit <F2> in the very first tab that was opened by vim, nerdtree opens just fine. But in the subsequent tabs, <F2> causes nerdtree to open in its own tab (it opens a scratch tab with just nerdtree).

How do I make sure that nerdtree opens just fine always? I don't need to open nerdtree by default for every tab or every time I open vim. But I need to hit <F2> to open it up so that I can open other files when needed.

  • 3
    I don't have a solution to your problem, but as someone who 1) has spent some time trying to fight against NERDTree to make it work how I wanted 2) has been on this site for a while and have seen a lot of new Vimmers fighting against this plugin, I would advise you to read this and not to waste your time with NERDTree: you will probably never make it work as you want and eventually you'll realize there are much better tools to use. Still I hope someone on here can find a solution to your problem :) – statox Apr 17 at 16:20
  • 1
    Also autocmd VimEnter * NERDTree only executes :NERDTree once after vim has started so I don't think it has anything to do with opening NERDTree for every tabs. See :h VimEnter for more details. – statox Apr 17 at 16:22
  • 3
    To reiterate what @statox said, NERDTree is a good plugin if you don't ever try to change any of its behavior. Judging from your affinity to tree-style file viewer and using tabs instead of buffers (here's a blog talking about this case), I'm assuming you're a new Vim user. So, if you don't mind, I'd suggest trying out more "vimmy" file browsers like vim-dirvish. There is also netrw plugin shipped with Vim, which also has tree style view. BTW, netrw is also not that great. – klaus Apr 17 at 17:13
  • And, you should consider using the issue tracker of the plugin itself for issues regarding using a plugin. – klaus Apr 17 at 17:14
  • @statox thanks for sharing your wisdom! I'll admit that I've heard similar opinions about NERDTree from others. – Dharmit Apr 18 at 8:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.