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.

Short version: How can I make the less utility in Linux not wrap lines?

Long version: Often I need to view huge CSV files using less with hundreds of columns. I frequently only care about the first couple columns. However, word wrap causes one line to become several lines even on wide-screen monitors.

share|improve this question

4 Answers 4

up vote 165 down vote accepted

-S option, see also the man-page.

share|improve this answer
103  
... and toggle inside less with the same keys (-, then Shift-S). –  user112553 Apr 19 '11 at 16:27
14  
I knew it had to be something. The man page calls wrapping folding and non-wrapping chopping. –  User1 Apr 19 '11 at 16:36
3  
@user112553 Lol, "chopping" is a great example of old fashioned GNU computer terminology. –  Ciro Santilli Jan 20 at 11:56

If you want to stop wrapping permanently, cast these spells:

echo "#env" >> ~/.lesskey
echo "LESS = -S" >> ~/.lesskey
lesskey
share|improve this answer
5  
+1 for beautiful spells. –  timss Jul 3 '13 at 18:48
    
It's far more straightforward, IMO, to simply set the LESS variable in your shell RC. I'm not sure if the LESS variable is supported as widely as the very old lesskey mechanism, but if so, I'd recommend using it. –  Ryan Long Jan 31 at 22:39

Don't know if less has a option for that, but I use the most command which does that by default (and allows scrolling left/right to view it)

share|improve this answer
3  
That sounds like a useful utility. Unfortunately most Linux distros don't have that tool by default. Sorry, I just couldn't help the pun. –  User1 Apr 19 '11 at 16:52
    
most seems like a nice program, but I can't believe it doesn't have a shortcut to go to the end of the file. The convenient less command "G" asks for line number and doesn't recognize "$". While it seems like it mimics less in certain ways, I don't understand why the author didn't make it fully compatible. –  haridsv Oct 31 '12 at 10:39
1  
@haridsv Pretty sure the End key works in less, to go to the end of the buffer; At least in my gnome-terminal –  ThorSummoner Jun 9 at 16:43

To setup git so it always does not wrap:

git config --global core.pager 'less -S'

share|improve this answer

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.