# auto(2m)

[Home] [Commands] [Variables] [Macro-Dev] [Glossary]

## NAME

auto - Automatic source file line type detection

## SYNOPSIS

auto Mode

A - mode line letter.

## DESCRIPTION

When this mode is enabled the line style of the source file, with respect to `CR/LF/CTRL-Z` characters, are automatically detected and the file (if saved) is written out in the same style as it was read in. This mode is designed to solve the problems of MS-DOS which utilize a '\r\n' with every new line and a ctrl-Z as a file terminator, conversely UNIX utilizes only '\n' as a line terminator.

auto mode therefore allows files to be edited across file system types without corrupting the line style of the native platform.

At load time, if auto detects CR/LF style line feeds then it enables the buffer modes cr(2m) and lf(2m); if a CTRL-Z is found at the end of the file then mode ctrlz(2m) is enabled. Otherwise these modes are cleared.

At write time, if auto mode is enabled then the file is written out is a style determined by modes cr, lf and ctrlz. For example, if cr and lf were enabled and ctrlz disabled then the file would be written out with new lines as '\r\n' and with no ending ctrl-z.

If auto is not enabled then the file is written out in the style of the current platform, regardless of the current settings on modes cr, lf and ctrlz.

## SUMMARY

The operation on the modes may be summarized as follows:-

## UNIX Systems

- auto Enabled UNIX and MS-DOS files may be edited normally, edits are saved in the format read by the system.
- auto Disabled UNIX files may be edited normally, files saved as UNIX files. MS-DOS files show a `^M` character at the end of each line (editing is not advised if the purity of the MS-DOS is to be maintained), any edits are written back as displayed on the screen.

## MS-DOS Systems

- auto Enabled UNIX and MS-DOS files may be edited normally, edits are saved in the format read by the system.
- auto Disabled on reading all files are read and editing may be undertaken normally. On writing, '\r's and a ctrl-Z are automatically added. The act of reading a UNIX file and re-writing it translates it to an MS-DOS file.

## NOTES

This mode MUST be enabled globally when the file is loaded for the file style to be correctly detected.

It is strongly advised that auto mode is permanently enabled.

Windows systems tend to use a '\r\n' style line feed but with no trailing ctrl-z.

## SEE ALSO

Operating Modes, global-mode(2), buffer-mode(2), cr(2m), lf(2m), ctrlz(2m), $buffer-fmod(5).

(c) Copyright JASSPA 2009
Last Modified: 2009/10/03
Generated On: 2009/10/12

</HMTL>