this post was submitted on 13 Nov 2023
1 points (100.0% liked)

Emacs

311 readers
2 users here now

A community for the timeless and infinitely powerful editor. Want to see what Emacs is capable of?!

Get Emacs

Rules

  1. Posts should be emacs related
  2. Be kind please
  3. Yes, we already know: Google results for "emacs" and "vi" link to each other. We good.

Emacs Resources

Emacs Tutorials

Useful Emacs configuration files and distributions

Quick pain-saver tip

founded 1 year ago
MODERATORS
 

Is there some way to make visual-line-mode more smart about line-breaks? As depicted in fig.1, visual-line-mode doesn't really handle overly-long lines (e.g. due to URLs) well. Disabling it entirely makes a bad overall trade-off in files containing mostly textual lines (fig.2).

It could improve by allowing line-breaks on some non-whitespace characters (like "-" or "/") or simply disabling visual-line-mode entirely for "words" that anyway need more than one line. Better yet, for any word exceeding a maximum character-length (e.g. 50) in order to better handle lines containing a few words, but also a moderately long URL (e.g. when using the markdown syntax [link name](link url)).

I've found no existing options in the M-x customize interface, nor any relevant packages in M-x package-list-packages (including MELPA).

Fig.1 When breaking long \"words\" like URLs, visual-line-mode is not very smart about where to break the lines.

Fig.2 For URLs, having no visual-line-mode line breaks active would be preferable, but the disadvantage of disabling visual-line-mode for lines with actual text is too big to just disable visual-line-mode entirely.

top 3 comments
sorted by: hot top controversial new old
[–] [email protected] 1 points 1 year ago

The following solutions won't break long URLs more intelligently but may be useful alternatives. You can use (setq word-wrap t). It will allow line breaking at any space or tab character but without visual-line-mode. See C-h v word-wrap. In this case, maximum character length, as hoped in your message above, is the width of the window. I typically make my windows narrower if I want fewer character columns per line. On some occasions, I have used Olivetti mode to enforce a better reading experience but with wider windows.

[–] [email protected] 1 points 1 year ago (1 children)
[–] [email protected] 1 points 1 year ago

Yes, it did :) Though it set off some Odyssey of things to fix with my config after upgrading my Emacs version ^^'