How to jump back to NERDTree from file in tab?

VimIdeNerdtree

Vim Problem Overview


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.

Vim Solutions


Solution 1 - Vim

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

Solution 2 - Vim

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

Solution 3 - Vim

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.

Solution 4 - Vim

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.

Solution 5 - Vim

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.

Solution 6 - Vim

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.

Solution 7 - Vim

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

Solution 8 - Vim

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.

Solution 9 - Vim

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

Solution 10 - Vim

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

Solution 11 - Vim

gt = next Tap gT = previous Tab

Solution 12 - Vim

All The Shortcuts And Functionality is At

press CTRL-?

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionNikita FedyashevView Question on Stackoverflow
Solution 1 - Vimrg88View Answer on Stackoverflow
Solution 2 - VimNouarView Answer on Stackoverflow
Solution 3 - VimjorelliView Answer on Stackoverflow
Solution 4 - ViminnaMView Answer on Stackoverflow
Solution 5 - VimSUDO Los AngelesView Answer on Stackoverflow
Solution 6 - VimGiuseppe RicuperoView Answer on Stackoverflow
Solution 7 - VimVineeth PradhanView Answer on Stackoverflow
Solution 8 - VimVerebView Answer on Stackoverflow
Solution 9 - VimsfrankView Answer on Stackoverflow
Solution 10 - VimNoahRayView Answer on Stackoverflow
Solution 11 - VimHyoView Answer on Stackoverflow
Solution 12 - VimAkashView Answer on Stackoverflow