Don't change the cursor position when scrolling in Emacs
Solution 1:
I think you want the behavior of cursor(point) and visible area should be like in notepad
, gedit
, others modern editors: ability to change visible area independently of point position and to immediately return visible area to point position after moving point. But emacs
has another conception: the visible area always follows the point position and vise versa.
See also https://stackoverflow.com/questions/9616623/ctrl-up-down-style-scrolling-in-emacs
Previous answer shows special idiom: if you want to move the visible area (with the point together) far from current position and then to return the point in exactly the previous position you should have a habit to use mark-ring
. There always is a way through mark ring
to current working position: many commands, like isearch-forward
, beginning-of-buffer
, ace-jump-mode
automatically save previous position in mark ring
and you shouldn't use C-<SPC> C-<SPC>
before, but only C-u C-<SPC>
for jumping back. Scrolling commands, like scroll-up
or mwheel-scroll
, don't automatically save previous position by default because it may produce too many excessive marks.
You can use commands clone-indirect-buffer
or view-buffer-other-window
for independent work with buffer in few places. And use command recenter-top-bottom
(C-l
) to continuously hold point in center of visible area.
Solution 2:
I don't know if there is a way to stop emacs from moving your point when scrolling. But if you would like to save your location to return to it later, you can use the mark ring.
That is, type C-<SPC> C-<SPC>
to push the current point location onto the mark ring, then later type C-u C-<SPC>
to set point to the previous location in the mark ring.