Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Switching to a particular tab in VIM

Tags:

vim

tabs

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/Ctrl-n for switching to adjacent tabs?

Also, I was trying to write a key mapping which will give a variable as input to a function and do the operation. For instance, let's say I press Ctrl-5 and a function (written by the user) will be called and given as input 5, and the cursor will go to tab 5 (if there is any 5th tab opened).

Can you please suggest how this can be done?

like image 675
Sumit Avatar asked Jan 05 '10 10:01

Sumit


People also ask

How do I switch between Nerdtree tabs?

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

How do I switch between tabs in Vim Mac?

Under the menu on the right, click on the plus (+) to add a new command. Choose MacVim for the application, and for the menu title, type "Select Next Tab", and choose a shortcut (I chose Cmd+right arrow). Then do the same thing for the command "Select Previous Tab".

How do I switch between windows in Vim?

To move from the current Vim window to the next one, type CTRL-W j (or CTRL-W <down> or CTRL-W CTRL-J). The CTRL-W is the mnemonic for “window” command, and the j is analogous to Vim's j command, which moves the cursor to the next line.


1 Answers

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)

like image 66
Antony Hatchkins Avatar answered Oct 17 '22 01:10

Antony Hatchkins