I would like each line of a file to show up on just a single line in the terminal when viewing the file with less. less -S is not working for me, no matter how I try. With the flag -S, whether specified on the command line or in the program (entering -S<CR> in less), the line continues onto the line below, wrapped.

For a terminal emulator I am using urxvt, if that matters, with the following options:

rxvt-unicode (urxvt) v9.19 - released: 2013-10-27
options: perl,xft,styles,combining,blink,iso14755,unicode3,encodings=eu+vn+jp+jp-ext+kr+zh+zh-ext,fade,transparent, tint,pixbuf,XIM,frills,selectionscrolling, wheel,slipwheel,smart-resizecursorBlink,pointerBlank,scrollbars=plain+rxvt+NeXT+xterm

And this is in .Xdefaults:

URxvt.depth:                32
URxvt.geometry:             90x30
URxvt.transparent:          false
URxvt.fading:               0
URxvt.loginShell:           true
URxvt.saveLines:            50
URxvt.internalBorder:       3
URxvt.lineSpace:            -7

! Fonts
URxvt*font: xft:Monospace:pixelsize=20
URxvt*boldFont: xft:Monospace:pixelsize=20:style=bold
! Fix font space
URxvt*letterSpace: -1

Plus some other options for color scheme.

It's not working with gnome-terminal, either, so maybe it's not something having to do with urxvt.


less --version gives less 458 (GNU regular expressions).

Neither $less nor $LESS are set.

  • any environment variables interfering with your plans? aliases? – mdpc Nov 29 '17 at 0:23
  • 1
    What is the output of "echo $LESS" and of "less --version"? – gmarmstrong Nov 29 '17 at 0:24
  • Edited with this information. – ammodramus Nov 29 '17 at 0:32
  • Ah, my .bashrc was aliasing less with less -r, which must interfere with -S. Removing the alias fixed the problem. – ammodramus Nov 29 '17 at 0:33
  • @ammodramus Yes, you are correct. linuxquestions.org/questions/ubuntu-63/… – Timothy Martin Nov 29 '17 at 0:36

Per mdpc's suggestion, I looked at aliases and found my .bashrc was aliasing less with less -r so that less can display colors. Removing this alias and thus removing the -r flag fixed the problem and made the -S flag produce the expected behavior.

From man less:

 -r or --raw-control-chars
          Causes "raw" control characters to be displayed.  The default is to display control characters using the caret  nota-
          tion;  for  example,  a control-A (octal 001) is displayed as "^A".  Warning: when the -r option is used, less cannot
          keep track of the actual appearance of the screen (since this depends on how the screen responds to each type of con-
          trol character).  Thus, various display problems may result, such as long lines being split in the wrong place.

So -r seems to break -S, understandably.

  • In order to retain displaying colors you should use the -R option instead of -r, which is compatible with -S. – egmont Nov 30 '17 at 12:13

Your Answer

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

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