9

Given a file which contains new lines, using Textmate, how can i remove them from the document

Given a text file

a


b

c

I'd like to end up with

a
b
c
James Raitsev
  • 92,517
  • 154
  • 335
  • 470

2 Answers2

30

I would use the regular expression ^\s*$\n which will match any line that is empty or contains only whitespace characters.

Just run Replace All with that in the Find box, and with the replace box empty.

Joel Westberg
  • 2,656
  • 1
  • 21
  • 27
3

Replace "\n+" with "\n" (be sure that "regular expression" checkbox is on). This replaces several consecutive linebreaks with only one.

Sergio Tulentsev
  • 226,338
  • 43
  • 373
  • 367