0

This answer shows how to position the cursor at an offset of a specified number of characters from the beginning of the buffer, namely by executing M-x goto-char 47 (for an offset of 47 characters from the buffer's beginning). How can I position the cursor at an offset of a specified number of character from the buffer's end?

1 Answer 1

1

You can achieve that using

(goto-char (- (buffer-size) offset))

Where you replace 'offset' with some number. (You can run the command using M-:)

Alternatively, you could first jump to the end of the buffer using M-> end then jump back a certain number of characters using a numerical prefix by pressing C-u 'some-number' followed by C-b.

2
  • Thanks. Is there a way to specify the buffer size as an argument to goto-char when using the M-x-goto-char version? Say, something along the lines of M-x-goto-char-(-(buffer-size) 47)?
    – Evan Aad
    Commented Dec 13, 2022 at 9:49
  • 1
    Not that I know of. But you can easily create a custom command for it of course. (here is another link to how to create a command). Commented Dec 13, 2022 at 9:52

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.