2

I'm very new to vim and found bindings Ctrl-F for page down and Ctrl-B for page up kind of inconvenient. I intuitively try to page up with Ctrl-F and page down with Ctrl-B because F is higher than B.

QUESTION: Is there a way to swap this two combinations?

8

Yes. You can change just about anything you want to change in Vim. Just do

nnoremap <C-f> <C-b>
nnoremap <C-b> <C-f>

Add those two mappings in your vimrc file and you've both of those commands swapped.

nnoremap - Maps new key combinations to existing commands without affecting any other commands that might be using the original command.

The mnemonic for me is,

f - forward
b - backward

So, whenever I want to go forward in the page, I press Ctrl + F and Ctrl + B for going backward.

  • Its not just something I use. It is probably how the command was intended to be remembered as. – Durga Swaroop Sep 24 '16 at 8:47
  • There are other ways to move around in the file; the keys ^F and ^B move forward and backward a page, keeping a couple of lines of continuity between screens so that it is possible to read through a file using these rather than ^Dand ^U if you wish. – KCCole Dec 3 '17 at 20:04
  • This is from Bill Joy's original paper on vi. – KCCole Dec 3 '17 at 20:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.