36

Is there a way to tell the terminal not to wrap long lines. I wish to see a line in the same space without wrapping to the next one. I do not care if I can not see the end of the line just as long as the line stays in one. A horizontal scroll would be good for this also but for the moment the removal of the wrapping is what I need.

1

3 Answers 3

41

It depends on what application you are using.

If you are viewing a file or command output using less, passing the -S option (a.k.a. --chop-long-lines) will cause output to be chopped off rather than wrapping to a new line. You can use the horizontal arrow keys to view the rest of the line.

For generic non full screen applications, you can turn off line wrapping by sending an appropriate escape sequence to the terminal:

tput rmam

This mode can be cancelled with a similar escape:

tput smam

Details on adjusting the behaviour for a few other command line tools can be found here:

http://tomayko.com/writings/StupidShellTricks

6
  • Nice link although I did not expect something like that to change the behavior. +1. Oct 29, 2011 at 15:59
  • 10
    Very interesting. I tried this with gnome terminal, and it sorta-kinda works, but it is also causing output to be chopped off. What I'd prefer is for the terminal to 'pretend' it had infinite line width, so it would just keep writing the line and then I could retrospectively go see the rest of the line by resizing or scrolling in the terminal window somehow. Is this possible?
    – wim
    Feb 12, 2013 at 2:49
  • Does this automatically reset when a new bash/sh is made? Eg, is this, or is this not; persistent? Jul 16, 2015 at 16:22
  • It is a runtime configuration of the terminal rather than a user configuration. So it won't carry over to a new terminal instance, but should carry forward to new things running in the terminal provided the behaviour isn't reset. Jul 19, 2015 at 13:30
  • @JamesHenstridge Is there any way to enable wrap? I don't like moving left and right to read the rest of the text on line.
    – Shayan
    Sep 22, 2019 at 13:41
15

To disable line wrapping in terminal more generally, you can use:

setterm -linewrap off

-1

Leaving aside the wrapping thing, you can zoom out/ zoom in in terminal to see all the content you need in one line.

For me is :

  • Ctrl+Shift++ - to zoom in
  • `Ctrl+- - to zoom out

Hope this helps

You must log in to answer this question.

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