3

I have buffer and I end up at 1616 column (I have one very long line, bug string). Is there a way to scroll the beginning of the line with a single commands. Is there a way to reset the buffer without killing it and opening again?

EDIT:

If fixed itself when I opened help screen and then close it. But from time to time I end up with state like this.

To reproduce the state, press CTRL+X < when truncate-lines is set to nil.

6
  • 1
    Doesn't C-a work? If not, what is the mode of the buffer? And what is the value of truncate-lines in the buffer?
    – NickD
    Apr 12 at 11:44
  • @NickD it don't work, the mode was Emacs-Lisp and JavaScript-mode. truncate-lines is set to nil. When I opened help to see the variable description and closed to resolved itself. But I would like to know how to exit this broken state, since I sometimes end with state like this.
    – jcubic
    Apr 12 at 11:59
  • @NickD I was able to reproduce the same state when using CTRL+X < when truncate-lines is set to nil.
    – jcubic
    Apr 12 at 12:05
  • 1
    I can reproduce it too: I'm not sure how C-x < (bound to scroll-left) is supposed to work, but this feels like a bug to me. You might want to report with M-x report-emacs-bug.
    – NickD
    Apr 12 at 14:20
  • Is this really about scrolling, which is a window movement? Or is it just about moving the cursor to the beginning of the line? (The latter can imply the former, of course.)
    – Drew
    Apr 12 at 15:21
5

The window has been scrolled left (scroll-left) for some reason.

C-x < or C-<next> can get you into this state.

C-x > or C-<prior> can get you out of this state.

Note those commands are blocked by default. When using them the first time, you will be asked, whether or not to enable them, in the minibuffer.

Note: if you press two times C-x < then you need to press two times C-x > to get back to your initial view.

2

Just adding to answer by @jue above.

The C-x < ("scroll-left") command horizontally scrolls all text lines to the left, which means that the window's view "pans" to the right. The emacs doc section on Horizontal-Scrolling does a pretty good job of explaining.

The way to get out of this pickle is as follows:

  1. Get back to start-of-line view. One of these will work, depending on emacs version:
    C-u 0 M-x toggle-truncate-lines to make long lines fold and undo any horizontal left scrolling.
    Press C-x > (or Ctrl-PageUp) as many times needed to get back to the start-of-line.

  2. Disable the scroll-left command in the current emacs process:
    Do: M-x eval-expression RET and enter the elisp expression:
    (put 'scroll-left 'disabled t)

  3. Make sure that scroll-left isn't enabled by default. Check your .emacs init file and delete line that has:
    (put 'scroll-left 'disabled nil)

Hope this helps.

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.