BigFish
BigFish

Reputation: 77

Vim: <C-b> move cursor to the last line of screen (if the cursor is not at that position)

I want <C-b> move cursor to the last line of screen if the cursor is not at the last line, otherwise, scroll page down.

ps: I know there is an internal variable for cursor position, I'd be grateful if you tell me where to find variables like that.

Upvotes: 2

Views: 457

Answers (1)

Kent
Kent

Reputation: 195089

Assuming that you are talking about "the last line in the window".

You can create an <expr> mapping to achieve that:

nnoremap <expr> <c-b> line('.')==line('w$')?'<c-f>':'L'
  • It checks if the current line is the last line in the current window
  • True: <c-f> next page, you can also change it into <c-d>
  • False: L, go to the last line in the current window.

Upvotes: 2

Related Questions