Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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)

share|improve this question
    
What do "less 418" and "less 458" mean? Are they version numbers? Access rights? Formatting specifications? –  Peter Mortensen Jul 6 '14 at 19:33
    
@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. –  Warren Young Jun 17 at 21:39

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer
    
+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 –  DilithiumMatrix Jul 6 '14 at 16:08
1  
Oh, you didn't mention. Does setting less -r as Git pager work in that case? –  slhck Jul 6 '14 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? –  DilithiumMatrix Jul 6 '14 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 Jul 6 '14 at 16:18
    
That's very strange! Maybe this is unique to me then. –  DilithiumMatrix Jul 6 '14 at 16:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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