Switching to a particular tab in VIM

Solution 1:

use 5gt to switch to tab 5

:tabn[ext] {count}

{count}gt

Go to tab page {count}. The first tab page has number one.

you can also bind it to a key:

:map <C-5> 5gt
:imap <C-5> <C-O>5gt

(Mapping Ctrl-<number> could be different/impossible for some terminals. Consider Alt-<number> then)

Solution 2:

Tackling only your first question, and quoting from help tabs in vim:

{count}gt       Go to tab page {count}.  The first tab page has number one.
{count}gT       Go {count} tab pages back.  Wraps around from the first one
                to the last one.

ie, typing 3gt goes to the third tab, 3gT goes 3 tabs back from the current tab.

Solution 3:

Just for sharing the key mapping to jump into particular tab directly. Please put them into _vimrc and make it work.

" Jump to particular tab directly
"NORMAL mode bindings for gvim
noremap <unique> <M-1> 1gt
noremap <unique> <M-2> 2gt
noremap <unique> <M-3> 3gt
noremap <unique> <M-4> 4gt
noremap <unique> <M-5> 5gt
noremap <unique> <M-6> 6gt
noremap <unique> <M-7> 7gt
noremap <unique> <M-8> 8gt
noremap <unique> <M-9> 9gt
noremap <unique> <M-0> 10gt

"INSERT mode bindings for gvim
inoremap <unique> <M-1> <C-O>1gt
inoremap <unique> <M-2> <C-O>2gt
inoremap <unique> <M-3> <C-O>3gt
inoremap <unique> <M-4> <C-O>4gt
inoremap <unique> <M-5> <C-O>5gt
inoremap <unique> <M-6> <C-O>6gt
inoremap <unique> <M-7> <C-O>7gt
inoremap <unique> <M-8> <C-O>8gt
inoremap <unique> <M-9> <C-O>9gt
inoremap <unique> <M-0> <C-O>10gt