Shortcut to switch tabs in MacVim

Solution 1:

Since MacVim is an actual program on Mac OS, you can map tab switching the same way you map commands in any program (which I personally just learned about recently).

Open up System Preferences, select "Keyboard", then "Application Shortcuts" (in the left menu). 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".

"Select Next Tab" and "Select Previous Tab" are found in MacVim under the "Window" menu. Any option you see in any of the menus for an app can be remapped using this method.

Solution 2:

You can of course change shortcuts with OSXs system preferences for your keyboard as shown here: How to Remap Any Keyboard Shortcut in Mac OS X

Some might prefer to do it via their .vimrc:

if has("gui_macvim")
  " Press Ctrl-Tab to switch between open tabs (like browser tabs) to 
  " the right side. Ctrl-Shift-Tab goes the other way.
  noremap <C-Tab> :tabnext<CR>
  noremap <C-S-Tab> :tabprev<CR>

  " Switch to specific tab numbers with Command-number
  noremap <D-1> :tabn 1<CR>
  noremap <D-2> :tabn 2<CR>
  noremap <D-3> :tabn 3<CR>
  noremap <D-4> :tabn 4<CR>
  noremap <D-5> :tabn 5<CR>
  noremap <D-6> :tabn 6<CR>
  noremap <D-7> :tabn 7<CR>
  noremap <D-8> :tabn 8<CR>
  noremap <D-9> :tabn 9<CR>
  " Command-0 goes to the last tab
  noremap <D-0> :tablast<CR>
endif

Solution 3:

You can Select Next Tab with +} and Select Previous Tab with +{

The shift key is required to not just hit a [ instead of a }
So the shortcut is +shift+] or +shift+[
This shortcuts works in many apps, i.e. in the Terminal