How to let Ctrl + Page Down switch tabs inside Vim in Terminal.app?

If you don't have actual pageup and pagedown keys on your keyboard there is no way to map these to anything.

  • <C-PageDown> is an alternative to :tabnext, :tabn and gt.
  • <C-PageUp> is an alternative to :tabprevious, :tabN and gT.

I strongly suggest you use gt and gT instead, they follow Vim's grammar (lowercase letter for "forward commands", uppercase for "backward commands") and so are very easy to memorize.

If you don't like gt/gT you can map them to something more to your taste:

nnoremap <C-Up> gT
nnoremap <C-Down> gt

But I don't think it's necessary.

Your example (a PageUp/PageDown-less keyboard) seems to be a rather nice example of the intelligence of Vim's seemingly weird design decisions.

--EDIT (as per the asker's request)--

I found the correct escape sequences. In Terminal.app's keyboard settings,

set "control page up" to "send string to shell:", with this value: "\033[5;5~"

set "control page down" to "send string to shell:", with this value: "\033[6;5~"


Based on ramn's answer and just as a reference, this is how to solve this problem in iTerm2:

  1. Go to iTerm / Preferences... / Profiles / Keys
  2. Press the + button to add a profile shortcut
  3. Use shortcut: ^Page Up, action: "Send Escape sequence", value [5;5~
  4. Use shortcut: ^Page Down, action: "Send Escape sequence", value [6;5~