Use M-x replace-regexp
to replace all non-whitespace characters by x
. You can use C-M-%
to run query-replace-regexp
and, once a match is found, press !
to replace all matches.
Now for a regexp that matches non-whitespace characters. You'd think that the character class [:space:]
would match whitespace characters, and so you'd use [^[:space:]]
as the regexp to mean “any non-whitespace character”. But in LaTeX mode, newlines have the “comment end” syntax instead of the “whitespace” syntax, so they don't count as whitespace for the purpose of [:space:]
. So you need to use the regexp
[^[:space:]
]
To enter a newline in the regexp, press C-q C-j
: the command C-q
means to enter the next character literally instead of interpreting it as a command, and C-j
(not the C-m
character that the Enter key sends) is the newline character.
That is, you type:
M-x replace-regexp RET
[^[:space:] C-q C-j ] RET
x RET
Note that this replaces all non-whitespace, including LaTeX commands, comments, etc.
Why not use lipsum instead?
ipsum
, a LaTeX package for generating lines of example text?