Navigation

Operators and Keywords

Function List:

C++ API

: untabify (t)
: untabify (t, tw)
: untabify (t, tw, deblank)

Replace TAB characters in t with spaces.

The input, t, may be either a 2-D character array, or a cell array of character strings. The output is the same class as the input.

The tab width is specified by tw, and defaults to eight.

If the optional argument deblank is true, then the spaces will be removed from the end of the character data.

The following example reads a file and writes an untabified version of the same file with trailing spaces stripped.

fid = fopen ("tabbed_script.m");
text = char (fread (fid, "uchar")');
fclose (fid);
fid = fopen ("untabified_script.m", "w");
text = untabify (strsplit (text, "\n"), 8, true);
fprintf (fid, "%s\n", text{:});
fclose (fid);

See also: strjust, strsplit, deblank.

Package: octave