Change tab size of "cat" command

The first command here emulates the formatting you see in vim. It intelligently expands tabs to the equivalent number of spaces, based on a tab-STOP (ts) setting of every 4 columns.

printf "ab\tcd\tde\n" |expand -t4   

Output

ab  cd  de

To keep the tabs as tabs and have the tab STOP positions set to every 4th column, then you must change the way the environment works with a tab-char (just as vim does with the :set ts=4 command)

For example, in the terminal, you can set the tab STOP to 4 with this command;

tabs 4; printf "ab\tcd\tde\n" 

Output

ab  cd  de

Just use the following code:

tabs -n

Where n is the number of spaces you want tabs to correspond too. In order to not having to do this every time you start the shell, just edit your .bash_profile in ~/ and add the above line to the end of the file.

For further info about the tabs command, refer to:

man tabs

There's no notion of tabs or tab stops in cat; the program just funnels the inputs to the output and treats tabs like any other character. If the output device happens to be a terminal, tabs will be handled according to whatever behavior the terminal is configured to provide.

Systems implementing POSIX.1 have a command called tabs(1) that will adjust the terminal's concept of how tabs should be displayed. Depending on a particular tab layout is not considered a good idea, as someone may send your file to some other device such as a printer that won't do what you intended.

When you adjust ts in vim (or plain vi), all you're doing is adjusting how the editor interprets tab characters when displayed. It has no bearing on what ends up in the file.