When I go to NERDTree and press 's', a split happens on the RIGHT side of the screen (I have splitright enabled)
Now if I go back to the NERDTree panel and press 'enter' on another file, the LEFT split gets replaced.
I would like all opening of files to happen on the right split. Is there a way to do this?
Anyone fixed this one or found a way to hack this issue yet? I also find this to be very annoying.
Add set splitright to your init.vim file.
press s key for opening to the right, i for opening to the bottom, enter for opening it in the current split
NERDTree uses the previous window as a reference. o or Enter opens the buffer in that window. With 'splitright', s will split that window, and open your buffer in the rightmost of those two windows. Here is what's happening in your scenario. I'll show the command/keystroke, and the resulting windows. 'splitright' is set, and â–ˆ indicates where the cursor is.
1. Start vim |â–ˆ[No Name] |
2. :NERDTree |â–ˆNERDTree_1 |[No Name] |
3. s |NERDTree_1 |[No Name] |â–ˆfile1 |
4. <C-W>h |NERDTree_1 |â–ˆ[No Name] |file1 |
5. <C-W>h |â–ˆNERDTree_1 |[No Name] |file1 |
6. o |NERDTree_1 |â–ˆfile2 |file1 |
If you change the way you get to the NERDTree window, by wrapping around the screen, you see different behavior.
1. Start vim |â–ˆ[No Name] |
2. :NERDTree |â–ˆNERDTree_1 |[No Name] |
3. s |NERDTree_1 |[No Name] |â–ˆfile1 |
4. <C-W>w |â–ˆNERDTree_1 |[No Name] |file1 |
5. o |NERDTree_1 |[No Name] |â–ˆfile2 |
You could use 99<C-W>h instead of <C-W>w.
If you let NERDTreeQuitOnOpen=1 in your vimrc, then you will see this.
1. Start vim |â–ˆ[No Name] |
2. :NERDTree |â–ˆNERDTree_1 |[No Name] |
3. s |[No Name] |â–ˆfile1 |
4. :NERDTreeToggle |â–ˆNERDTree_1 |[No Name] |file1 |
5. o |[No Name] |â–ˆfile2 |
This is the correct behavior, giving a NERDTree user more control over where the splits occur, especially as the number of windows increases.
@PhilRunninger
As you say above, I set NERDTreeQuitOnOpen=1, and then:
1. Start vim |â–ˆ[No Name] |
2. :NERDTree |â–ˆNERDTree_1 |[No Name] |
3. s |[No Name] |â–ˆfile1 |
4. :NERDTreeToggle |â–ˆNERDTree_1 |[No Name] |file1 |
5. i |[No Name] |â–ˆfile2 |
|â–ˆfile3 | |
I want file3 opened under file2 not [No Name], how?
@dodowhat While vertical splits work as described in my comment above, horizontal splits don't follow that behavior. There is a pull request (#941), which addresses this. I haven't heard back from the author, so I may have to fix it up and make these changes myself. I believe I won't add the new setting, but change the default behavior to match the vertical split's.
Reopening so my new PR can close it officially.
Most helpful comment
press
skey for opening to the right,ifor opening to the bottom,enterfor opening it in the current split