3

Running spacemacs 0.200.

I am sorry if it is too basic. But I am just not able to get this.

How do I convert two consecutive newlines with some text, say, 'there were two newlines here'?

I could see the notation for special character classes like [[:alnum:]], etc. But no clue about newlines.

Drew
  • 75,699
  • 9
  • 109
  • 225
deshmukh
  • 1,852
  • 13
  • 29

1 Answers1

3

Interactively, you can use replace-regexp for this. Type C-q C-j to insert a newline character in the minibuffer (so you would need to type this twice).

In Elisp strings you can use \n to indicate a newline, so you would write (re-search-forward "\n\n") to search for two consecutive newlines. You can then use a replace-match command for the replacement.

phils
  • 48,657
  • 3
  • 76
  • 115
StarBug
  • 479
  • 4
  • 10