From 808850a4645ddba76657ee35b21120cb9d58a185 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Thu, 19 Jun 2008 22:35:36 +1200 Subject: [PATCH] dont open a file twice in the same tab with o mapping if the user tells the nerd tree to open a file (without splitting), and that file is already open in the current tab, then just stick the cursor in the existing window for the file --- plugin/NERD_tree.vim | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 64e1c1e..d7dfb53 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -2104,7 +2104,12 @@ endfunction function! s:OpenFileNode(treenode) call s:PutCursorInTreeWin() - if s:ShouldSplitToOpen(winnr("#")) + "if the file is already open in this tab then just stick the cursor in it + let winnr = bufwinnr(a:treenode.path.StrForOS(0)) + if winnr != -1 + exec winnr . "wincmd w" + + elseif s:ShouldSplitToOpen(winnr("#")) call s:OpenFileNodeSplit(a:treenode) else try