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?
Add a comment
|
1 Answer
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
.
-
Thanks. Is there a way to specify the buffer size as an argument to
goto-char
when using theM-x-goto-char
version? Say, something along the lines ofM-x-goto-char-(-(buffer-size) 47)
?– Evan AadCommented Dec 13, 2022 at 9:49 -
1Not 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