While trying to improve output from hg diff, I noticed that less’s -F option does not work with its -S option. Why is that happening and how can I achieve the desired effect?

Here is an extract from man:

   -F or --quit-if-one-screen
      Causes less to automatically exit if the entire file can be dis-
      played on the first screen.

   -S or --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.

Tested on less 444 and less 436.


I was mistaken in thinking that -S will cut excess bytes. Content goes to the right of the screen.

To achieve what I wanted I could just use (...) | cut -b -80 | less -FSX.

  • Do you really want to -S? If lines are longer than your output, the remainder will just be discarded, and you will lose information in your diff. Also, since I am passing by: I hope you use the color extension to get colorized diffs. May 11, 2012 at 10:06
  • @Daniel: I feel that spanning long lines through multipe lines is a little bit messy. When using less if change does not show up in first 80 columns I can always temporarily expand my term window. :)
    – seler
    May 11, 2012 at 10:27
  • Without the color extension it gets very messy, but with it I have no issues. But we are all different human beings :-) . May 11, 2012 at 11:20
  • @Daniel, I've never said that I do not use color extension. This question is about less, not hg.
    – seler
    May 11, 2012 at 13:26

1 Answer 1


Works for me; less -FS exits immediately if the input can be printed on one screen without folding lines, and acts normally if scrolling (either to the right or down) is needed.

  • I've got less 444. Which version are you using?
    – seler
    May 11, 2012 at 10:57
  • @seler: less 443, but I've upgraded to 444 and it behaves the same.
    – jpalecek
    May 12, 2012 at 11:03
  • I've been testing on Debian and Xubuntu under gnome terminal. What's your system and terminal?
    – seler
    May 14, 2012 at 6:25
  • Are you sure that in your testing file you've got lines longer than your terminals width?
    – seler
    May 14, 2012 at 7:04
  • @seler: Yes, sure. I generate the input with echo, like this echo xxxxxxxxxxxxxxxxx | less -SF -, where I enter enough xs that they wrap over and fill the whole line. The system is Debian sid, terminal is konsole. I tried it in the console, too, and saw slight difference in the behavior: in console, less prints the file when it would fit on one screen, under konsole, it doesn't (just exits). That is, however, dependent just on the -F parameter (doesn't depend on -S).
    – jpalecek
    May 14, 2012 at 22:41

You must log in to answer this question.

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