How to jump back to NERDTree from file in tab?
Asked Answered
R

13

272

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.

Rounce answered 1/11, 2009 at 7:18 Comment(1)
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?Hennie
U
756

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).

Uhf answered 1/11, 2009 at 7:31 Comment(10)
>>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 helpRounce
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.Hennie
As might your assumption of my guess, Manni.Uhf
I think this answer is better!Heedful
What if I push W three times?Glossematics
We search for this answer :)Vendee
Excellent answer +1. But Is it documented in the NERDTree documentation? Actually I didn't find it out.Humour
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)Uhf
It should be in the NERDTree doc... Actually this is not a NERDTree command but a basic Vim command.Panier
If you don't want to cycle through the windows just use 1 ctrl-ww to jump to the first windows which is NTMarisolmarissa
F
223

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

Flagler answered 12/8, 2014 at 0:30 Comment(0)
F
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.

Fairleigh answered 11/12, 2010 at 21:26 Comment(2)
it helps a lot to put a :NERDTreeToggle keybinding in your .vimrc. I use <F4>, but that's just me. I put project.vim, taglist, and NERDTree on <F2>, <F3>, and <F4>, 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.Fairleigh
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!Wie
H
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.

Hennie answered 1/11, 2009 at 13:39 Comment(1)
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.Glomerate
L
31

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.

Lubin answered 6/10, 2012 at 23:14 Comment(1)
press ctrl after 1 is indeed a long journey.Vercelli
M
17

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.

Minnow answered 3/4, 2020 at 14:31 Comment(0)
D
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

Douzepers answered 12/10, 2014 at 16:34 Comment(0)
L
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 :)

Literature answered 26/10, 2020 at 16:2 Comment(1)
ctrl+ww was what I was looking forAleta
C
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.

Cental answered 1/11, 2009 at 13:37 Comment(0)
I
5

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

Invalidate answered 12/10, 2017 at 19:20 Comment(0)
K
2

gt = next Tap gT = previous Tab

Kurbash answered 20/12, 2020 at 7:3 Comment(0)
W
2

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

put set mouse=a

after that you enable files click in NERDTree.

Waterway answered 9/8, 2022 at 10:18 Comment(0)
L
0

All The Shortcuts And Functionality is At

press CTRL-?

Latinism answered 26/2, 2020 at 10:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.