Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

While trying to improve output from hg diff I've noticed that less -F option does not work with -S option. Why is that happening and how to achieve desired effect?

Here is handout 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 by thinking that -S will cut excess bytes. Content goes to the right screen.

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

share|improve this question
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. – Daniel Andersson May 11 '12 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 '12 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 :-) . – Daniel Andersson May 11 '12 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 '12 at 13:26
up vote 1 down vote accepted

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.

share|improve this answer
I've got less 444. Which version are you using? – seler May 11 '12 at 10:57
@seler: less 443, but I've upgraded to 444 and it behaves the same. – jpalecek May 12 '12 at 11:03
I've been testing on Debian and Xubuntu under gnome terminal. What's your system and terminal? – seler May 14 '12 at 6:25
Are you sure that in your testing file you've got lines longer than your terminals width? – seler May 14 '12 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 '12 at 22:41

Your Answer


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.