3

Using less +-S does not work (although it does ask Chop long lines (press RETURN)), and entering -S once inside less also does not work. Is there a solution?

I am usig OS X Mavericks (10.9.3).

less 418 (default) or less 458 (via MacPorts)

3
  • What do "less 418" and "less 458" mean? Are they version numbers? Access rights? Formatting specifications? Commented Jul 6, 2014 at 19:33
  • 1
    @PeterMortensen: They're the less version number as output by less --version. OS X still ships version 418 in Yosemite, by the way, and I see the same buggy behavior with less -S on Yosemite, so this question is not dead, even if it is "answered". I've seen this behavior for years and years on multiple OSes, though so my belief is that less -S is just plain buggy. Commented Jun 17, 2015 at 21:39
  • How about icdiff: github.com/jeffkaufman/icdiff
    – zhanxw
    Commented Dec 15, 2019 at 3:58

1 Answer 1

3

You can use fold to first wrap the text, then pipe to less:

fold -w 78 | less

Of course, -w sets the number of characters. By default it's 80. fold is POSIX and bundled with OS X.


Apparently, using less -r as the default Git pager will also achieve folding of long lines.

Otherwise, while the diff is being displayed, you can type -S, then Enter to toggle chopping/folding long lines.

5
  • +1 for a cool work-around, but I'm actually hoping to use this for the (git) diff command --- so I don't think this will work Commented Jul 6, 2014 at 16:08
  • 1
    Oh, you didn't mention. Does setting less -r as Git pager work in that case?
    – slhck
    Commented Jul 6, 2014 at 16:10
  • Yes! That works! (I saw that on this question but didn't try it because my man page said less -r did something completely different. Any idea why this works in git, but not terminal? Commented Jul 6, 2014 at 16:13
  • I have no idea why exactly. I just remembered this trick. I'm curious why less -+S doesn't work in your case. In fact, in my setup (also under OS X), the diff shown in less is automatically line-wrapped, but I haven't set anything explicitly to enable it.
    – slhck
    Commented Jul 6, 2014 at 16:18
  • That's very strange! Maybe this is unique to me then. Commented Jul 6, 2014 at 16:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .