• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Remove all blank lines of code

Community Beginner ,
Mar 01, 2024 Mar 01, 2024

Copy link to clipboard

Copied

I am using the most current Dreamweaver.

 

I have code with a many blank lines.  How can I remove them?  The old solutions online do not work.

 

I have tried this regular expression:

^(?:[\t ]*(?:\r?\n|\r))+

 

It works but does not work using "Replace All" so I have to hit enter 200-500 time for each php file.

 

Any solutions would be appreciated!

 

Views

209

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Mar 03, 2024 Mar 03, 2024

Assuming you've set your Code Format Settings and gone through each tag with your Tag Library Editor,  clicking Apply Source Formatting (the paint bucket icon on the Common Toolbar) might clean up some of the unwanted spaces for you.  See screenshots.

 

image.png

 

image.png

 

 

 

Votes

Translate

Translate
Community Beginner ,
Mar 01, 2024 Mar 01, 2024

Copy link to clipboard

Copied

kevink92448460_0-1709336068204.png

Example :up_arrow:

 

How I want it to look:

kevink92448460_1-1709336163605.png

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 01, 2024 Mar 01, 2024

Copy link to clipboard

Copied

What types of tools have you tried online? A thought I am having is if you minify the code, and use a tool to unminify I'm wondering if those spaces would be removed in that process.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 01, 2024 Mar 01, 2024

Copy link to clipboard

Copied

I haven't tried any to minify.  My hope is I can do this in Dreamweaver.  Apparently this used to work but doesn't in later versions of Dreamweaver.

 

Open the file
Click CTRL + F
Select "Current document" in "Find in" (You can also select the folder if you have multiple files)
Search in "Source code"
Tick "Use regular expression"
Type "[\r\n]{2,}" (without quotes) in "Find"
Type "\n" (without quotes) in "Replace"
Press "Replace All"

//This removes all blank lines in Dreamweaver.
//Make sure to untick regular expression afterwards!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 03, 2024 Mar 03, 2024

Copy link to clipboard

Copied

Use Code Minify.

https://codebeautify.org/minify-html

 

 

Nancy O'Shea— Product User, Community Expert & Moderator
Alt-Web Design & Publishing ~ Web : Print : Graphics : Media

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 03, 2024 Mar 03, 2024

Copy link to clipboard

Copied

Assuming you've set your Code Format Settings and gone through each tag with your Tag Library Editor,  clicking Apply Source Formatting (the paint bucket icon on the Common Toolbar) might clean up some of the unwanted spaces for you.  See screenshots.

 

image.png

 

image.png

 

 

 

Nancy O'Shea— Product User, Community Expert & Moderator
Alt-Web Design & Publishing ~ Web : Print : Graphics : Media

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 04, 2024 Mar 04, 2024

Copy link to clipboard

Copied

LATEST

Thank you everyone for your reponses but this worked for me perfectly!  I can't belive I didn't know this existed.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 04, 2024 Mar 04, 2024

Copy link to clipboard

Copied

quoteI haven't tried any to minify.  My hope is I can do this in Dreamweaver.  Apparently this used to work but doesn't in later versions of Dreamweaver.
By @Schmonkee

 

Try testing with the following expression set:

place in the search field

 

(>)\s+|\s+(?=<)

 

and, in the replacement field

 

$1

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines