How can I switch in and out of NERDtree?
Asked Answered
P

3

5

Is there a way to switch in and out of NERDtree -- mouse disabled? I know I can press 'q' to quit NERDtree and go back to text editor, but when I go back to NERDtree it doesn't keep track of which directories I had pressed open before, and I would like to keep the list of directories open. I referenced NERDtree help, but I couldn't find what I was looking for. Perhaps I missed something?

Thanks in advance.

Ptarmigan answered 17/5, 2015 at 19:35 Comment(0)
T
12

NERDTree opens as a sidebar next to the existing open windows. You can therefore use all Vim window movement commands to jump back and forth.

For example, <C-W>p (that's Ctrl + W followed by P) goes back to the previous window, and 1<C-W><C-W> goes to the first window (which usually is the leftmost split NERDTree). You'll find the whole list at :help window-move-cursor; for effective window handling, it's important you know these very well.

Textualist answered 17/5, 2015 at 19:59 Comment(0)
H
4

As a potential best practice, I map F2 key to toggle NERDTree.

In your vimrc:

map <F2> :NERDTreeToggle<CR>
let NERDTreeWinSize=32
let NERDTreeWinPos="left"
let NERDTreeShowHidden=1
let NERDTreeAutoDeleteBuffer=1
let NERDTreeAutoDeleteBuffer=1

And also, I map Ctrl+j/k/h/l to quickly move between opened vim windows.

"Smart way to move between windows
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
Hartzog answered 31/5, 2015 at 4:28 Comment(0)
B
3

To switch between the NERDtree "window" and the text "window" with

Ctrl+w and then right arrow

and then to go back I use

Ctrl+w and then left arrow

For more info on "vim windows"

http://vimdoc.sourceforge.net/htmldoc/windows.html

Bicephalous answered 17/5, 2015 at 19:43 Comment(2)
Using the cursor keys is rather ineffective and unusual for Vim. Fortunately, the home-row alternatives <C-w>l and <C-w>h work as well.Textualist
Plus on MacOS these keys cycle through the desktops available.Windpipe

© 2022 - 2024 — McMap. All rights reserved.