0

My text is written in paragraphs that are split into lines, which makes it difficult to search for strings that might be spanned across several lines. For instance, given the following text

This is an example
of a text.

when searching for the string "example of" in an unmodified emacs version it finds no occurrences. However, if I add the following customization, which was suggested in another post on the emacs stack exchange, the search works as desired:

(setq isearch-lax-whitespace t)
(setq isearch-regexp-lax-whitespace t)
(setq search-whitespace-regexp "[ \t\r\n]+")

My question is how to configure the query-replace operation (M-%) so that it will behave as my modified search operation, i.e., be able to find and replace strings, while ignoring white spaces.

0

Ask Emacs. C-hkM-% tells you the answer:

If replace-lax-whitespace is non-nil, a space or spaces in the string to be replaced will match a sequence of whitespace chars defined by the regexp in search-whitespace-regexp.

  • In that case C-h C-h will be enlightening. – phils Oct 1 '15 at 11:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.