Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do <C-PageUp> and <C-PageDown> not work in vim?

I have Vim 7.2 installed on Windows. In GVim, the <C-PageUp> and <C-PageDown> work for navigation between tabs by default. However, it doesn't work for Vim.

I have even added the below lines in _vimrc, but it still does not work.

map <C-PageUp> :tabp<CR>
map <C-PageDown> :tabn<CR>

But, map and works.

map <C-left> :tabp<CR>
map <C-right> :tabn<CR>

Does anybody have a clue why?

like image 288
Morgan Cheng Avatar asked Nov 29 '09 01:11

Morgan Cheng


2 Answers

The problem you describe is generally caused by vim's terminal settings not knowing the correct character sequence for a given key (on a console, all keystrokes are turned into a sequence of characters). It can also be caused by your console not sending a distinct character sequence for the key you're trying to press.

If it's the former problem, doing something like this can work around it:

:map <CTRL-V><CTRL-PAGEUP> :tabp<CR>

Where <CTRL-V> and <CTRL-PAGEUP> are literally those keys, not "less than, C, T, R, ... etc.".

If it's the latter problem then you need to either adjust the settings of your terminal program or get a different terminal program. (I'm not sure which of these options actually exist on Windows.)

like image 126
Laurence Gonsalves Avatar answered Oct 19 '22 18:10

Laurence Gonsalves


This may seem obvious to many, but konsole users should be aware that some versions bind ctrl-pageup / ctrl-pagedown as secondary bindings to it's own tabbed window feature, (which may not be obvious if you don't use that feature). Simply clearing them from the 'Configure Shortcuts' menu got them working in vim correctly for me. I guess other terminals may have similar features enabeld by default.

like image 35
agd Avatar answered Oct 19 '22 18:10

agd