Nikita Fedyashev
Nikita Fedyashev

Reputation: 18993

How to jump back to NERDTree from file in tab?

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.

Upvotes: 275

Views: 143795

Answers (13)

ealvess
ealvess

Reputation: 549

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

put set mouse=a

after that you enable files click in NERDTree.

Upvotes: 2

Hyo
Hyo

Reputation: 23

gt = next Tap gT = previous Tab

Upvotes: 2

NoahRay
NoahRay

Reputation: 116

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

Upvotes: 6

Giuseppe Ricupero
Giuseppe Ricupero

Reputation: 6272

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.

Upvotes: 18

Akash
Akash

Reputation: 2803

All The Shortcuts And Functionality is At

press CTRL-?

Upvotes: 0

Nouar
Nouar

Reputation: 3247

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

Upvotes: 224

sfrank
sfrank

Reputation: 131

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

Upvotes: 5

rg88
rg88

Reputation: 20977

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

Upvotes: 764

Vineeth Pradhan
Vineeth Pradhan

Reputation: 8371

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

Upvotes: 9

jorelli
jorelli

Reputation: 8350

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.

Upvotes: 102

SUDO Los Angeles
SUDO Los Angeles

Reputation: 1635

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.

Upvotes: 31

innaM
innaM

Reputation: 47829

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.

Upvotes: 80

Vereb
Vereb

Reputation: 14716

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.

Upvotes: 5

Related Questions