Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 903
Jeff Avatar asked Jun 11 '13 21:06

Jeff


2 Answers

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.

like image 63
Ingo Karkat Avatar answered Oct 03 '22 20:10

Ingo Karkat


What about the following mappings?

nnoremap <PageUp> gg
nnoremap <PageDown> G

Or simply using gg and G?

like image 33
romainl Avatar answered Oct 03 '22 20:10

romainl