2

I can't get emacs to scroll horizontally!

To replicate the problem:

  1. Open the *scratch* buffer.
  2. Write a long line.
  3. Make the long line exceed the window width with M-xtoggle-truncate-lines. The left hand text (column 0) will now be off the left of the window.
  4. Try M-xscroll-left or its shortcut C-x < to scroll left.
  5. Type y to enable the disabled commands.
  6. NOTHING HAPPENS!

I also tried C-a to go to the beginning of the line.

I also tried M-xtoggle-horizontal-scroll-bar but got the error message "Horizontal scroll bars aren't implemented yet".

There seems to be no way to scroll horizontally!

I need this because I have many wide CSV files to read.

I'm using the latest prelude on emacs 24.5 on Windows 10.

I filed an issue on the prelude project in case it is a genuine bug and could be fixed there.

Cœur
  • 37,241
  • 25
  • 195
  • 267
blokeley
  • 6,726
  • 9
  • 53
  • 75
  • As @choroba said, `C-x <` scrolls the opposite way from what you wanted. You can use `C-x >` instead. But `C-a` also works - it automatically scrolls the window completely, to show you the beginning (left side). (And `C-e` works in the other direction. Perhaps you have something else going on. Does `C-a` not work for you if you start Emacs using `emacs -Q` (no init file)? It works for me. – Drew Feb 16 '16 at 16:59
  • `C-a` does work but **only if point is on a long line**! Thanks for commenting. – blokeley Feb 16 '16 at 17:01
  • I guess you mean only if point is on a line that is truncated on the left? – Drew Feb 16 '16 at 17:06

4 Answers4

2

You seem not to understand how horizontal scrolling works. It's not intuitive, that's why the command is disabled by default.

When I press C-x< at the end of the long line, the line disappears to the left. When I press C-x> there, nothing happens.

Pressing C-x< at the beginning of the long line, though, shows the second part of the long line.

Consider using visual-line-mode or even the csv-mode instead.

choroba
  • 231,213
  • 25
  • 204
  • 289
  • 2
    Blimey! You're right. The scrolling works the opposite way to what anyone sane would expect. Bizarrely, if you `C-a` on a short line which is off the left of the window, nothing happens. That's the time when you would **most** want horizontal scrolling to work. Thanks for explaining the weirdness. No wonder Atom's getting popular(!) – blokeley Feb 16 '16 at 16:43
  • 1
    I think you'll find it's just another case of Emacs implementing its behaviours long before anything else was ever considered to be the 'expected' behaviour. FWIW horizontal scrolling in Emacs doesn't bother me in the slightest because it works the way I expect it to. You either get used to how it works, or you customise the commands to work the way you want them to. – phils Feb 16 '16 at 19:23
  • I think it was just a poor, internally inconsistent design choice that's too hard to change now. `C-v` is `scroll-up-command` (i.e. reveal text lower than the bottom of the screen), and `v` resembles a down arrow. `C-x >` should therefore be `scroll-left` (i.e. reveal text rightward of the right of the screen) but is actually `scroll-right`. It's just a keybinding I guess! – Jeremy Field Jan 05 '22 at 04:27
1

There is new a feature in Emacs 26. You can customize mwheel-tilt-scroll-p and use mouse to scroll.

  1. M-x customize group RET mouse
  2. Then set mwheel-tilt-scroll-p to t
DJJ
  • 2,481
  • 2
  • 28
  • 53
stone2009
  • 11
  • 1
1

No need to handroll it yourself. This is provided out of the box in emacs 27, and it probably was available for longer:

This feature is off by default; the variable mouse-wheel-tilt-scroll turns it on, if you customize it to a non-nil value.

(setq mouse-wheel-tilt-scroll t)
dmvianna
  • 15,088
  • 18
  • 77
  • 106
0

Sounds like xemacs have horizontal scroll in a 'natural' way. As far as I can see it there is a [Options] button in the menubar, when clicking on it there is a [Frame Appearance] sub menu and there, there are 2 button []scrollbars, [] Truncate Lines

When these 2 buttons are checked in, long line are truncated and scrolling is smooth.

May be xemacs is non standard though.

I use it, I find it easy to cut/paste even rectangular areas, selection is faster and more precise to me that what I could achieve with keyboard meta-ctrl-shift stroke alone.

Cheers Phi I

Phi
  • 735
  • 7
  • 22