44

Is it possible for less output to set the tab width to a number X as it is for cat?

polym
  • 10,672
  • 9
  • 41
  • 65
  • 2
    You don't need to change the tabs length setting to output a file with reduced tab size. Just use `expand` instead of `cat`, like so: `expand -4 residuum.txt`. – dotancohen Jul 30 '14 at 16:49

3 Answers3

58

Yes, it is possible with less -x or less --tabs, e.g. less -x4 will set the tabwidth to 4.

You can configure defaults with the LESS environment variable, e.g. LESS="-x4".

hvrauhal
  • 103
  • 3
Residuum
  • 1,046
  • 1
  • 11
  • 17
  • 1
    Thanks for your fast response! Didn't find the option. I'll accept your answer as soon as it is possible :)! – polym Jul 30 '14 at 14:32
36

The less-specific answer has already been given, but a generic solution (for any pager) is to expand the tabs (with space characters) with the expand command before feeding to the pager:

expand -t4 file | pager
Stéphane Chazelas
  • 522,931
  • 91
  • 1,010
  • 1,501
10

Instead of setting the tab width in command line (before you open less). You can also set the tab width within less by typing -x4

Sungam
  • 201
  • 2
  • 3