Switching to a particular tab in VIM

前端 未结 3 448
感动是毒
感动是毒 2020-12-12 20:19

I was trying to switch from a tab to another tab (which may not be adjacent to the previous tab) in VIM. Is there any shortcut for that, like we have Ctrl-p<

相关标签:
3条回答
  • 2020-12-12 20:54

    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)

    0 讨论(0)
  • 2020-12-12 20:56

    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.

    0 讨论(0)
  • 2020-12-12 20:58

    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
    
    0 讨论(0)
提交回复
热议问题