views:

857

answers:

3

I have an entry in my .vimrc which makes it page down the viewport when I hit the spacebar. It looks like this:

map <Space> <PageDown>

I want to create another key mapping which pages the viewport up when holding shift and hitting the spacebar. I have tried the following entries:

map <Shift><Space> <PageUp>
map <S-Space> <PageUp>

Neither work. Anybody know how to achieve this functionality?

+3  A: 

Use this:

map <Space> ^D   " Pagedown when press Space
map <S-Space> ^U " Page Up when press Shift Space

To get the ^D and ^U symbol correctly just press Control-V Control-D, and Control-V Control-U

CMS
Works on my machine! :-)
Adam Liss
When doing this, it pages down when using both Space and Shift Space... I have tried this in Debian Linux and OS X. I am running VIM 7.0 and VIM 7.2 respectively
sant0sk1
+4  A: 

You cannot. CMS's solution will work for gVim, but not in vim because terminals cannot distinguish between <Space> and <S-Space> because curses sees them the same. It might be possible in the future if vim gains libtermkey support and your terminal supports the proper <CSI> sequences (xterm does if properly configured; nothing else does yet).

Zathrus
Might want to edit your answer...cannot distinguish between what? I assume you mean the terminal cannot distinguish between CTRL-SPACE and simple SPACE by itself.
m0j0
Oops, yes, it was eating everything between less than and greater than signs. Fixed.
Zathrus
A: 

im in win xp . vim 7.3 , map space 5j , works . but s-space dont works , i dont know why ? is it some setting overlap them ? ..................... i use noremap s-space 5k , it works . and i think some plugins maybe overlap this function . noremap it cool . but i still dont know the reason .

hblan