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

Open new tab only if it doesn't exists, otherwise switch to the already open tab. #439

Closed
moeabdol opened this issue Apr 22, 2015 · 3 comments

Comments

@moeabdol
Copy link

I <3 NERDTree; however, my memory falls short most of the time when trying to remember which tabs I have opened. Or even worse, I get lazy eyeballing and verifying if a certain tab is already open.
When I select a file in NERDTree and press t to open it in a tab, I realize I have now two tabs open that are pointing to the same file. For example.
| Foo.txt | Bar.txt | Foo.txt |

This was also documented on stack overflow
http://stackoverflow.com/questions/27172873/vim-nerdtree-how-to-prohibit-duplicate-files-in-tabs

It would be really cool if NERDTree would switch to the existing tab.

This issue if solved, will shutdown all NERDTree haters especially them oil-vinegar, ctrl-p netrw trolls.

@scrooloose
Copy link
Collaborator

Grab the latest version and stick this in ~/.vim/nerdtree_plugin/override_tab_mapping.vim

https://gist.github.com/scrooloose/0495cade24f1f2ebb602

Let me know if there are any problems :)

@moeabdol
Copy link
Author

Thanks @scrooloose works like a charm 👍

@kjyv
Copy link

kjyv commented Feb 12, 2016

If one also wants this for double clicking files (when configured to open in tabs), add the following line to that file (right after the first):
call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'callback': 'NERDTreeMyOpenInTab', 'scope': "FileNo de", 'override': 1})

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