Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open Nerdtree file in non-adjacent split

Tags:

vim

nerdtree

Normally I switch over to the Nerdtree file buffer by hitting Ctrl+H twice to move the cursor over to the left edge of the screen. However, this means that when I open files, they are always in the split adjacent to the NERDTree window. How can I open files in the split that's not adjacent to the NERDTree window?

like image 277
Kevin Burke Avatar asked Jan 13 '12 18:01

Kevin Burke


People also ask

How do I open a NERDTree file?

If you want to use NERDTree, you can open NERDTree (type :NERDTree ), navigate to your file, and then press t with cursor on the file name. This will open specific file in new tab.


1 Answers

NERDtree will open a file in the previous window if you press o or enter. You can open it in a split of the previous window by pressing i, or in a vertical split by pressing s.

It sounds like you have Ctrl-H mapped to Ctrl-W h. The trick to not having NERDtree open the file into a window that is adjacent to the NERDTree window is to not have the adjacent window be the previous window.

To achieve this, toggle the NERDTree window closed. (:NERDTreeToggle, or whatever your mapkey is to toggle NERDTree). Then move to the appropriate window you want to open the file in. Then toggle NERDTree open again. Now you can open the file in the previous window that you were in using o or enter... or in splits using i or s.

To save having to toggle the NERDTree window open/close, you may want to set the option NERDTreeQuitOnOpen. Then you just need to open NERDTree when you're in a window that you intend to open a file into.

like image 68
darcyparker Avatar answered Sep 30 '22 23:09

darcyparker