19.9 Useless Whitespace
It is easy to leave unnecessary spaces at the end of a line, or
empty lines at the end of a file, without realizing it. In most
cases, this trailing whitespace has no effect, but there are
special circumstances where it matters.
You can make trailing whitespace at the end of a line visible on the
screen by setting the buffer-local variable
show-trailing-whitespace
to t
. Then Emacs displays
trailing whitespace in the face trailing-whitespace
.
This feature does not apply when point is at the end of the line
containing the whitespace. Strictly speaking, that is “trailing
whitespace” nonetheless, but displaying it specially in that case
looks ugly while you are typing in new text. In this special case,
the location of point is enough to show you that the spaces are
present.
To delete all trailing whitespace within the current buffer's
accessible portion (see Narrowing), type M-x
delete-trailing-whitespace <RET>. (This command does not remove
the form-feed characters.)
Emacs can indicate unused lines at the end of the window with a
small image in the left fringe (see Fringes). The image appears
for window lines that do not correspond to any buffer text. Blank
lines at the end of the buffer then stand out because they do not have
this image in the fringe.
To enable this feature, set the buffer-local variable
indicate-empty-lines
to a non-nil
value. The default
value of this variable is controlled by the variable
default-indicate-empty-lines
; by setting that variable, you
can enable or disable this feature for all new buffers. (This feature
currently doesn't work on character terminals.)