nerdtree icon indicating copy to clipboard operation
nerdtree copied to clipboard

Open file again in current split instead of switching to existing split

Open dexgs opened this issue 5 months ago • 1 comments

I often like to use a split view in vim to view multiple regions of the same file at once. Sometimes I switch one of the splits to a different file. I would like to use nerdtree to switch back to the same file, but when I select a file in nerdtree that is already open in another split, it simply focuses that split instead of opening the file in the split I was last using.

What is currently happening:

  • I Open 2 splits ("split 1" and "split 2")
  • I Open the same file ("file A") in both splits
  • I Open a different file ("file B") in "split 2"
  • I select "file A" in nerdtree after focusing "split 2"
  • "split 1" (which still has "file A" open) is focused, "split 2" still shows "file B"

What I would like to happen: After I select "file A" in nerdtree, I would like it to open in "split 2" instead of focusing "split 1"

Is there any configuration option to make nerdtree behave this way?

dexgs avatar Jul 26 '25 17:07 dexgs

I've found the NERDTreeCustomOpenArgs in the documentation and it seems like I should be able to set the reuse key to an empty value to get the behaviour I want.

I've tried putting the following into my Vim configuration file, but it doesn't change anything:

let g:NERDTreeCustomOpenArgs = {'file': {'reuse': '', 'where': 'p'}, 'dir': {}}

EDIT: This does actually change something, I should have read the documentation more closely. However, this setting only applies when I select a tree node with <CR>. I would like to have this same behaviour when I click on a node with the mouse. Is there any way to do that?

dexgs avatar Aug 15 '25 19:08 dexgs