Switching between tabs in NERDTree
Asked Answered
S

10

122

I've just started using the NERDTree vim plugin for my project.

I can't find the documentation for switching between opened tabs. Can anyone tell me the shortcut key[s] ?

Thanks...

Sixpence answered 9/3, 2010 at 22:18 Comment(2)
Note: The tabs functionality is a standard feature of vim (since version 7) - though NERDTree happens to put them to good useBacksheesh
I use macvim, which can use cmd+number to switch between many tabs and it's very convenient! For example press cmd+1 jump to tab1, cmd+5 jump to tab5Power
C
234

An additional option (and my personal choice)beyond the ones listed by Michael Madsen:

gt = next tab

gT = previous tab

Cantaloupe answered 9/3, 2010 at 22:33 Comment(3)
where did you get this information - I do not see it in doc when using ? for info in the treeOrganization
It seems like nerdtree is only open within 1 tab, so by switching to the other, the dir tree disappears.Khabarovsk
if NewdTree tab is closed, use ":NERDTreeFocus" to reopen it.Hydrotaxis
A
41

I like to bind my vim navigation keys to switching between tabs. Here are the lines from my .vimrc file:

map  <C-l> :tabn<CR>
map  <C-h> :tabp<CR>
map  <C-n> :tabnew<CR>

That way, I can switch between tabs using the left and right buttons just like I normally would move the cursor, except I just hold the Control key as well.

  • Control+l moves to the next tab
  • Control+h moves to the previous tab
  • Control+n creates a new tab
Asteria answered 10/3, 2010 at 6:15 Comment(2)
interesting. this will certainly com in handy. is it possible to change the mapping for VIM navigation commands like the difficult to hit SHIFT+$ ?Meroblastic
Are you referring to moving to the end of the line? If so, a simple command can do this 'map <C-l> $' or something similar.Asteria
W
17

A quick check in :h tabs reveals it's CTRL-Page Down to cycle between tabs. You can also use the :tabnext command (:tabn for short).

Wineglass answered 9/3, 2010 at 22:25 Comment(1)
Neither Ctrl button works when vim is run in terminal an using terminal tabs. If not using terminal tabs then either Ctrl worksGreenish
N
12

I use iTerm on the mac, and I like being able to switch to the next/previous tabs using Shift-[left arrow key] and Shift-[right arrow key]

From my .vimrc, here's how to do the same thing in MacVim;

  map <S-Right> :tabn<CR>
  map <S-Left>  :tabp<CR>

FYI, by default, the key combos Cmd-Shift-[ and Cmd-Shift-] will switch between tabs in MacVim (and in Google Chrome, Safari and probably a bunch of other stuff)

Nagpur answered 15/11, 2012 at 13:3 Comment(0)
M
10

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

Mufi answered 26/8, 2020 at 20:1 Comment(1)
This really worked like a charm. I am using vim in Ubuntu18. Thank you for your knowledge contribution. Appreciate itPorter
I
7

my settings

map <F2> :NERDTreeToggle<cr>
map <C-Right> :tabn<cr>
map <C-Left> :tabp<cr>
Interviewee answered 14/11, 2013 at 20:5 Comment(0)
A
7

To enable Tab navigation like firefox add this to your vimrc:

nnoremap <C-S-tab> :tabprevious<CR>
nnoremap <C-tab>   :tabnext<CR>
nnoremap <C-t>     :tabnew<CR>
inoremap <C-S-tab> <Esc>:tabprevious<CR>i
inoremap <C-tab>   <Esc>:tabnext<CR>i
inoremap <C-t>     <Esc>:tabnew<CR>
inoremap <C-S-w>   <Esc>:tabclose<CR>

Also this come in handy Use <A-Fn> to go to the nth tabpage

nnoremap <A-F1> 1gt
nnoremap <A-F2> 2gt
nnoremap <A-F3> 3gt
nnoremap <A-F4> 4gt
nnoremap <A-F5> 5gt
nnoremap <A-F6> 6gt
nnoremap <A-F7> 7gt
nnoremap <A-F8> 8gt
nnoremap <A-F9> 9gt
nnoremap <A-F10> 10gt 

Where,

  C --> ctrl key
  S --> Shift key
  A --> Alt key
  F1-10 --> Are the function keys

NOTE: Alt + f4 is usually used for closing of the windows. So check for that. If problem persists you can always map Ctrl or Shift key instead of Alt key, or use some combination of these.

Affix answered 21/10, 2014 at 14:47 Comment(0)
H
7

'{TabNumber} + gt' will allow you toggle to tab {TabNumber}.

For example, going to tab 1 will be keying '1' followed by 'g' and 't'.

The tab number is incremental from 1 left to right.

Herzegovina answered 11/5, 2017 at 0:4 Comment(2)
This answer is awesome!Clavicle
is there a command to "toggle to last tab" or "toggle to first tab" ?Miso
R
3

Adding to digitalronin's answer, I think that the primary browser shortcut (at least in Chrome and Firefox) for switching tabs is option+command+right or left arrow.

If you want to keep your NERDTree Vim setup consistent with that, then this variation would work.

 map <D-A-Right> :tabn<CR>
 map <D-A-Left>  :tabp<CR>
Replevy answered 7/2, 2013 at 0:24 Comment(0)
R
1

You can configure vim to switch between tabs using Ctrl + arrow keys.

Ctrl + arrow will switch to tab that is on the left of current tab.

Ctrl + arrow will switch to tab that is on the right of current tab.

To achieve above behaviour update your vimrc with following lines:

nnoremap <C-Left> :tabprevious<CR>
nnoremap <C-Right> :tabnext<CR>

Reference: Using vim tab pages

Resnick answered 24/7, 2021 at 12:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.