Follow @BPSPro

Remove Whitespace in Dreamweaver – White Space Removal Dreamweaver

1 Comment RSS Site Feed Author: AITpro Admin
Published: November 7, 2010
Updated: November 7, 2010

Problem:  Extra lines of whitespace appear in your PHP or HTML files in Dreamweaver after downloading your files from your server to your computer.  Scroll to the end of this Dreamweaver whitespace fix to make sure this is the problem you are trying to fix – shows before and after Dreamweaver whitespace screenshots.

Solution:

In Dreamweaver either right mouse click anywhere in your code in Code View and click Find and Replace, use Ctrl + F to launch the Find and Replace window, or click on the Edit menu and choose Find and Replace.  All of these methods will launch the Dreamweaver Find and Replace window shown below.

Click to enlarge image
Find and Replace Whitespace Dreamweaver

Find in:  Current Document should be selected unless you want to remove whitespace from several files all at once.
Search:  Source Code should be selected.
Find:  [\r\n]{2,}
Replace:  \n 
Options:  Use regular expressions should ONLY be selected (checked).
Click the Replace All button.

Make sure that if you copy and paste directly from this page that you do not have any whitespace after [\r\n]{2,} in the Find: window.  The blinking mouse cursor should be right after [\r\n]{2,} and not below it on a new line.  Nothing bad will happen if you do not do this, but the whitespace will also not be removed from your files.

If you have several Dreamweaver PHP or HTML files that you want to remove whitespace from or an entire website that needs to have whitespace removed from all files then I recommend that you only do one file first as a test before choosing other “Find in:” options like Entire Current Local Site, etc.

To permamently fix this problem in Dreamweaver from reoccurring each time you download and upload files to your server:

In Dreamweaver click the Edit menu, click Preferences, select Code Format under the Category window, select LF (Unix) for Line break type as shown in the screenshot below.

Click image to enlarge
Dreamweaver Whitespace Line Break Type

Before – Shows a file in Dreamweaver where additional lines of whitespace have been added between the lines of code in the file.

Dreamweaver Whitespace problem - Before

After – Shows that the whitespace between code lines has been removed in Dreamweaver.

Dreamweaver Whitespace Removal - After


Skip to toolbar