BBEdit-compatible regular expression to remove blank lines

I tried other regular expressions that are supposed to remove blank lines from the document, but none of them work in BBEdit find-and-replace.

What is a regular expression to remove blank lines from a document that will work in bbedit?

+4
source share
5 answers

I am going to suggest that there may be spaces in the lines you want to remove. This should do the trick:

^\s*?\r 

(replace with nothing, make sure the "Grep" checkbox is checked)

+5
source

It’s easier for me to select β€œText> Technological lines containing ...”, with the expression:

 ^$ 

or

 ^\s*$ 

Check the "Use grep" and "Delete matching lines" boxes. Uncheck all others.

+4
source

This works in code. (Not sure about BBEdit, though)

Search:

 \n\n 

Replaced by:

 \n 

Make sure the Use Regular Expressions option is checked.

+2
source

To delete all empty lines, regardless of the number of empty lines between non-empty lines, regardless of how much was regular or not.

You must act as follows:

1 you delete all empty lines with

  Β« Text Menu / Process Lines Containing... Β» > Regex : ^$ > Use grep enabled > Delete matched line enabled 

2d, if you want to restore readability, add an empty line after your blocks, for example

  Β« Search Menu / Find... Β» > Grep enabled > Find: ^}$ <<<< because the final curly is usually the 1st and the last char > Replace: }\n <<<< or \r or \r\c according to the Platform choice 
0
source

Find: \ r + Replace with: \ r

You need to check the Grep parameter.

0
source

All Articles