Glam Prestige Journal

Bright entertainment trends with youth appeal.

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.

4 Answers

Note: For the key binding, see the second part.

In less, it's called line folding rather than line wrapping.  To set it not to fold, use the -S option:

-S, --chop-long-lines

Causes lines longer than the screen width to be chopped rather than folded. That is, the portion of a long line that does not fit in the screen width is not shown. The default is to fold long lines; that is, display the remainder on the next line.

less(1)


Alternatively, as mentioned in the below comment, if you already opened the file, you can toggle the mode by typing -S (and then Enter for some implementations).

After disabling line folding, you can scroll sideways with the arrow keys.

4

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

echo "#env" >> ~/.lesskey
echo "LESS = -S" >> ~/.lesskey
lesskey
7

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)

3

To setup git so it always does not wrap:

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

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy