266

I usually:

  1. Choose the needed file.
  2. Open it in a tab(t character, by default).

But how I can jump back to NERDTree to open one more file in a tab?

Temporary solution I use now in my .vimrc file:

map <F10> :NERDTree /path/to/root/of/my/project

But it's not very useful to start navigation again and again from the root directory.

BinaryButterfly
  • 18,137
  • 13
  • 50
  • 91
  • 5
    I don't understand your update. No, the NERDTree isn't displayed in its own tab, but when you open a new file in a new tab, you should be able to use `gt` to jump back to the tab containing NERDTree? – innaM Nov 01 '09 at 13:52

13 Answers13

748

Ctrl-ww

This will move between open windows (so you could hop between the NERDTree window, the file you are editing and the help window, for example... just hold down Ctrl and press w twice).

hg8
  • 1,082
  • 2
  • 15
  • 28
rg88
  • 20,742
  • 18
  • 76
  • 110
  • 5
    >>just hold down "control" and press "w" twice. Unfortunately, I don't see anything changed after this.. And there's nothing special im my vimrc for this shortcut. Do you have any ideas? Please help – BinaryButterfly Nov 01 '09 at 08:31
  • 4
    Ctrl-ww will move the cursor between the split windows of the active tab. In a brand-new tab, there are not splits and thus ctrl-ww will do nothing. – innaM Nov 02 '09 at 06:54
  • 1
    As might your assumption of my guess, Manni. – rg88 Nov 02 '09 at 16:18
  • 2
    I think this answer is better! – DNB5brims Feb 21 '12 at 03:41
  • What if I push W three times? – AlienWebguy Apr 02 '13 at 22:14
  • We search for this answer :) – Salah Eddine Taouririt May 05 '13 at 14:49
  • Excellent answer +1. But Is it documented in the NERDTree documentation? Actually I didn't find it out. – Arup Rakshit Dec 25 '13 at 08:59
  • I'll be honest, I have no idea where I originally learned this. I probably found it worked in some other plugin and just gave it a shot (or even just fiddled around with pressing various key combinations to see what would happen and discovered it by accident... I don't recall) – rg88 Dec 25 '13 at 21:28
  • It should be in the NERDTree doc... Actually this is not a NERDTree command but a basic Vim command. – isar May 14 '16 at 20:23
  • 1
    If you don't want to cycle through the windows just use `1 ctrl-ww` to jump to the first windows which is NT – 0xMH Sep 25 '18 at 12:25
219

Ctrl+ww cycle though all windows

Ctrl+wh takes you left a window

Ctrl+wj takes you down a window

Ctrl+wk takes you up a window

Ctrl+wl takes you right a window

Nouar
  • 3,170
  • 1
  • 23
  • 21
102

NERDTree opens up in another window. That split view you're seeing? They're called windows in vim parlance. All the window commands start with CTRL-W. To move from adjacent windows that are left and right of one another, you can change focus to the window to the left of your current window with CTRL-w h, and move focus to the right with CTRL-w l. Likewise, CTRL-w j and CTRL-w k will move you between horizontally split windows (i.e., one window is above the other). There's a lot more you can do with windows as described here.

You can also use the :NERDTreeToggle command to make your tree open and close. I usually bind that do t.

Hulk1991
  • 3,079
  • 13
  • 31
  • 46
jorelli
  • 8,064
  • 4
  • 36
  • 35
  • 2
    it helps a lot to put a :NERDTreeToggle keybinding in your .vimrc. I use , but that's just me. I put project.vim, taglist, and NERDTree on , , and , respectively. Now it's easy to get around my projects. That works really poorly with MiniBufExplorer though, so if you use that you may have some issues. – jorelli Jan 11 '11 at 17:33
  • Thanks for this explanation. For some reason, it is not too obvious to a novice user that the NERDTree actually opens a new Vim window. Once I understood that, and learned a few commands to navigate windows, I not only started using NERDTree effectively, but Vim windows became a convenient way to open multiple files in the same screen! –  Oct 19 '17 at 11:12
80

If you use T instead of t there is no need to jump back because the new tab will be opened, but vim's focus will simply remain within NERDTree.

innaM
  • 47,505
  • 4
  • 67
  • 87
  • What if we are using buffers instead of tabs (as one is often told to do with Vim)? *edit: answer below is what I was looking for. – cbartondock Apr 26 '17 at 04:04
29

You can focus on a split window using # ctrl-ww.

for example, pressing:

1 ctrl-ww

would focus on the first window, usually being NERDTree.

SUDO Los Angeles
  • 1,555
  • 12
  • 10
16

Since it's not mentioned and it's really helpful:

ctrl-wp

which I memorize as go to the previously selected window.

It works as a there and back command. After having opened a new file from the tree in a new window press ctrl-wp to switch back to the NERDTree and use it again to return to your previous window.

PS: it is worth to mention that ctrl-wp is actually documented as go to the preview window (see: :help preview-window and :help ctrl-w).

It is also the only keystroke which works to switch inside and explore the COC preview documentation window.

Giuseppe Ricupero
  • 6,134
  • 3
  • 23
  • 32
9

ctrl-ww Could be useful when you have limited tabs open. But could get annoying when you have too many tabs open.

I type in :NERDTree again to get the focus back on NERDTree tab instantly wherever my cursor's focus is. Hope that helps

Vineeth Pradhan
  • 8,201
  • 7
  • 33
  • 34
6

The top answers here mention using T to open a file in a new tab silently, or Ctrl+WW to hop back to nerd-tree window after file is opened normally.

IF WORKING WITH BUFFERS: use go to open a file in a new buffer, silently, meaning your focus will remain on nerd-tree.

Use this to open multiple files fast :)

NoahRay
  • 116
  • 1
  • 3
5

You can change the tabs by ctrl-pgup and ctrl-pgdown. On that tab you came from the NERDTree is still selected and you can open another tab.

Vereb
  • 14,388
  • 2
  • 28
  • 30
4

In more recent versions of NERDTree you can use the command :NERDTreeFocus, which will move focus to the NERDTree window.

sfrank
  • 121
  • 1
  • 5
2

gt = next Tap gT = previous Tab

Hyo
  • 23
  • 3
1

if you want you can enable the mouse support editing ~/.vimrc file.

put set mouse=a

after that you enable files click in NERDTree.

ealvess
  • 519
  • 5
  • 12
0

All The Shortcuts And Functionality is At

press CTRL-?

Akash
  • 2,795
  • 1
  • 7
  • 11