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?


I believe you're looking for something like:

(setq scroll-preserve-screen-position 'always)
| improve this answer | |
  • Unfortunately, this will still scroll if e.g. point lands on an empty line. – Kodiologist Jan 5 at 13:03

Option goal-column might help in this regard. C-h v goal-column says:

goal-column is a variable defined in simple.el.

Its value is nil

Automatically becomes buffer-local when set.


Semipermanent goal column for vertical motion, as set by C-x C-n, or nil.

A non-nil setting overrides the variable line-move-visual, which see.

You can customize this variable.

| improve this answer | |
  • 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 Sep 26 '18 at 14:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.