0

I've been practicing to use VIM for some time now, but I still find the CTRL B behavior near the top of a file irritating and would like to know whether (or how) I can modify how it works.

Normally when one presses CTRL B, the visible buffer scrolls up by one page and the cursor jumps up by the same amount of lines. Near the top of a file, though, the visible buffer jumps to the beginnining of the file and the cursor is set to the last visible line.

What I would expect is that the cursor would be set to the first visible line. Can I enforce this behavior somehow?

Example (of current behavior): Assume a terminal window with space for 30 lines, the first visible line is 3, and the cursor is at line 20. If I press CTRL B the first visible line jumps to 1 and the cursor is now on the last visible line - line 30 (instead of the intended line 1).

1

Remap Ctrl-B ie <C-B>

Uppercase H moves cursor to top of page.

The 0 (zero) moves cursor to the start of line.

:nmap <C-B> <PageUp>H0

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.