set tab width for less output

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

Asked By: polym

||

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".

Answered By: Residuum

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
Answered By: Stéphane Chazelas

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

Answered By: Sungam
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.