3

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.

2
  • 1
    Please define "visible text". Are you referring to text properties? Whitespace? Other?
    – phils
    Nov 13 '17 at 10:51
  • @phils: I've added a clarification.
    – Evan Aad
    Nov 13 '17 at 11:43
3

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."

e.g.:

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

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

0

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.

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.