# clean(3)

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

## NAME

clean - Remove redundant white spaces from the current buffer

## SYNOPSIS

n clean

## DESCRIPTION

clean removes redundant white spaces from the current buffer, there are three types this command remove:

1)

Any space or tab character at the end of the line. All are removed until the last character is not a space or a tab, or the line is empty. Note that an empty line is not removed unless at the end of the buffer.

2)

Space characters are removed when the next character is a tab, making the space redundant, e.g. the strings "`Hello World`" and "`Hello World`" will look identical because the tab character (' ') indents the text to the 8th column with or without the space so the space can be removed.

3)

Superfluous empty lines at the end of the buffer are removed, leaving only one empty line.

4)

If argument n is given (value is not used) multiple blank lines are reduced to a single blank line.

## DIAGNOSTICS

`[Command illegal in view mode]`

Caused by a redundant white space being found and the buffer being in view mode. Note that if clean completes while the buffer is in view mode then no superfluous white spaces where found.

## NOTES

clean is a macro defined in `format.emf`.

Most of this command's operation is performed by simple regex search and replace strings:

a)

Search for: "[\t ]+$" Replace with: "\\0"

b)

Search for: "[ ]+\t" Replace with: "\t"

c)

Search for: "\n\n\n" Replace with: "\n\n"

It is useful to define a new command called spotless in the user macro file which cleans the file and removes blank lines. The new command is defined as follows:-

    ; spotless; Perform a clean and remove any multi-blank lines.
    define-macro spotless
        -1 clean
    !emacro

## SEE ALSO

replace-string(2), tab(2m), delete-blank-lines(2), tabs-to-spaces(3).

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

</HMTL>