Linux tabs command

Updated: 11/06/2021 by Computer Hope
tabs command

On Unix-like operating systems, the tabs command sets tab stops on a terminal.

This page covers the Linux version of tabs.


The tabs program clears and sets tab stops on the terminal. This uses the clear_all_tabs and set_tab capabilities of the terminfo database. If either is absent, tabs cannot clear or set tab stops. The terminal should be configured to use hard tabs, for example with the following stty command:

stty tab0


tabs [-n | --file [[-code] | -a | -a2 | -c | -c2 | -c3 | -f | -p | -s | -u]]
     [+m [n]] [-T type]


-Ttype Tell tabs which terminal type to use. If this option is not given, tabs uses the TERM environment variable. If that is not set, it uses the "ansi+tabs" standard which works well on many common terminal types.
-d This debugging option shows a ruler line, followed by two data lines. The first data line shows the expected tab stops marked with asterisks. The second data line shows the actual tab stops, marked with asterisks.
-n A repetitive specification requests tabs at columns 1+n, 1+2*n, etc., where n is a single-digit decimal number. Of particular importance is the value 8: this represents the UNIX system "standard" tab setting, and is the most likely tab setting to be found at a terminal. When -0 is used, the tab stops are cleared and no new ones are set.
-file If the name of a file file is given, tabs reads the first line of the file, searching for a format specification. If it finds one there, it sets the tab stops according to it; otherwise it sets them as -8.
+m[n] The margin argument may be used for some terminals. It causes all tabs to be moved over n columns by making column n+1 the left margin. If +m is given without a value of n, the value assumed is 10. The normal (leftmost) margin on most terminals is obtained by +m0. The margin for most terminals is reset only when the +m flag is given explicitly.
-code Use a pre-defined tab stop list for writing code. See pre-defined tab stop lists, below.

The tabs program processes a single list of tab stops. The last option to be processed which defines a list is the one that determines the list to be processed.

Explicit tab stop lists

An explicit list can be defined after the options (this does not use a "-"). The values in the list must be in increasing numeric order, and greater than zero. They are separated by a comma or a blank, for example,

tabs 1,6,11,16,21
tabs 1 6 11 16 21

Use a '+' to treat a number as an increment relative to the previous value, e.g.,

tabs 1,+5,+5,+5,+5

...which is equivalent to the 1,6,11,16,21 example.

Pre-defined tab stop lists

The X/Open standard defines several pre-defined lists of tab stops for certain coding styles, which can be set using the following -code options:

option tab stop definition coding style
-a 1,10,16,36,72 Assembler, IBM S/370, first format
-a2 1,10,16,40,72 Assembler, IBM S/370, second format
-c 1,8,12,16,20,55 COBOL, normal format
-c2 1,6,10,14,49 COBOL compact format
-c3 1,6,10,14,18,22,26,30,34,38,42,46,50,54,58,62,67 COBOL compact format extended
-f 1,7,11,15,19,23 FORTRAN
-p 1,5,9,13,17,21,25,29,33,37,41,45,49,53,57,61 PL/I
-s 1,10,55 SNOBOL
-u 1,12,20,44 UNIVAC 1100 Assembler


tabs -c

Set the terminal's tab stops for normal COBOL formatting.

tabs -d 13,19,29,36,43

Set the tab stops to 13, 19, 29, 36, and 43 spaces, and display a ruler which shows expected and real tab stops.

stty — Set options for your terminal display.