Is there a way of calling (end-of-buffer)
that excludes trailing empty lines?
Add a comment
|
We can go to the end of the buffer, then move backwards over whitespace:
(progn (goto-char (point-max))
(skip-chars-backward "\n[:space:]"))
If you want to call this interactively, make it into a command:
(defun end-of-buffer-before-whitespace ()
"Move point to after the last non-whitespace character in the buffer."
(interactive)
(goto-char (point-max))
(skip-chars-backward "\n[:space:]"))
-
2
-
Note, if you don't want the cursor to be at the line end, add
(move-beginning-of-line nil)
– ideasman42 Jun 18 '19 at 6:55