Jeff
Jeff

Reputation: 6110

How to remap Vim keys (PageUp and PageDown)

I want to remap <PageUp> to <C-u> and PageDown to <C-d> per the Vim scrolling documentation.

As it stands right now, my /etc/vim/vimrc looks like this:

nnoremap <PageUp> <C-u>
nnoremap <PageDown> <C-d>

I've tried a lot of different combinations and nothing I've done has worked.

My goal is to make the cursor move to the Start Of File or EOF when holding down PageUp/PageDown. As it is right now, the cursor stops before it gets all the way to the top (and PageDown scrolls past the EOF). Just annoyances I'm trying to fix.

EDIT: The above settings work fine. I was placing my mappings too early in the file.

Upvotes: 12

Views: 13827

Answers (3)

laktak
laktak

Reputation: 60003

You can do this with

map <silent> <PageUp> 1000<C-U>
map <silent> <PageDown> 1000<C-D>
imap <silent> <PageUp> <C-O>1000<C-U>
imap <silent> <PageDown> <C-O>1000<C-D>

from fixing-pageup-and-pagedown

Upvotes: 2

Ingo Karkat
Ingo Karkat

Reputation: 172580

Instead of placing the mappings into the system-wide /etc/vim/vimrc, you should put user customizations into the ~/.vimrc file. Nonetheless, the global configuration (if that's what you want) should work, too. That it doesn't means that the mappings get cleared or redefined. You can check with

:verbose nmap <PageDown>

If it didn't get redefined, you have to hunt for :nunmap commands in all loaded scripts (:scriptnames), or capture a log with vim -V20vimlog.

Upvotes: 6

romainl
romainl

Reputation: 196556

What about the following mappings?

nnoremap <PageUp> gg
nnoremap <PageDown> G

Or simply using gg and G?

Upvotes: 13

Related Questions