Is there a shortcut key combination for moving the cursor to the beginning, resp. end, of the visible text in the current buffer, i.e. to the first, resp. last, cursor position that can be seen on the current screen, without scrolling up or down? Contrast this with the absolute beginning/end of the text in the current buffer, for which the shortcuts M-<, resp. M->, will work.

  • @phils: I've added a clarification.
    – Evan Aad
    Commented Nov 13, 2017 at 11:43

2 Answers 2


Ah, you're looking to move point to the top or bottom of the window.

M-r calls move-to-window-line-top-bottom which cycles through the top/middle/bottom positions. You can also use a prefix argument, for which "zero means top of window, negative means relative to bottom of window."


  • M-0M-r
  • M--M-r

Or write a command to call move-to-window-line directly with an appropriate argument.


I like to use the following bindings to easily get to the top (t) and bottom (b):

(global-set-key (kbd "C-S-t") (lambda () (interactive)
                (push-mark (point)) ; save place
                                (let ((current-prefix-arg 0))
                  (call-interactively 'move-to-window-line-top-bottom))))
(global-set-key (kbd "C-S-b") (lambda () (interactive)
                (push-mark (point)) ; save place
                (let ((current-prefix-arg '(-1)))
                  (call-interactively 'move-to-window-line-top-bottom))))

They are specific calls to move-to-window-line-top-bottom (with needed prefix args) to go to those spots directly, instead of pressing M-r two or three times.

You may wish to use different bindings, but the recipe of going there directly is there.

  • You might want to rethink this code, hard. call-interactively isn't just unnecessary here because you can just call (almost all) interactive functions directly (like (move-to-window-line-top-bottom -1)), you could even save some indirection and call (move-to-window-line -1), the function move-to-window-line-top-bottom actually calls. Commented May 17, 2022 at 7:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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