I'm viewing a file containing visually aligned columns in truncate line mode, and would like to scroll vertically without changing my horizontal scroll position. But scroll-down always moves the cursor to the first column. Is there a simple way to prevent this, and keep the current horizontal point position?
2 Answers
I believe you're looking for something like:
(setq scroll-preserve-screen-position 'always) - Unfortunately, this will still scroll if e.g. point lands on an empty line.Kodiologist– Kodiologist2020-01-05 13:03:47 +00:00Commented Jan 5, 2020 at 13:03
Option goal-column might help in this regard. C-h v goal-column says:
goal-columnis a variable defined insimple.el.Its value is
nilAutomatically becomes buffer-local when set.
Documentation:
Semipermanent goal column for vertical motion, as set by
C-x C-n, ornil.A non-
nilsetting overrides the variableline-move-visual, which see.You can customize this variable.
- Thanks. It does the job, though it's behavior seems unintuitive as it is respected by C-n and C-p but not by C-v and M-v.Dov Grobgeld– Dov Grobgeld2018-09-26 14:44:10 +00:00Commented Sep 26, 2018 at 14:44