Written by me@grafxflow
16 Oct, 2012
12
13,548
I was recently working on a website in Dreamweaver and had both PHP and CSS files with loads of blank lines of code, which needed to be deleted in order to make the files smaller.
So instead of doing it manually one at a time... which would have taken ages. I used a nice little tip in Dreamweaver.
1. Open the document you need to change.
2. Click CMD + F (Mac) or CTRL + F (PC).
3. In the Find and Replace window change the following:
Find in: to Current document
Search: to Source code
Find: input [\r\n]{2,}
Replace: input \n
Options: tick Use regular expression. It is slightly different in versions of cc 2016+ where you now need to choose the dropdown button on the top right - see the second picture below.
4. Finally select Replace All.
5. Optional - To make life easier just use the floppy disk icon to save the 'search and replace' settings for reference. Another tip: Make sure you also have 'current document' selected since it saves this setting as well.
Minor update for CC 2016+ the 'floppy disk save' is no longer available by default but can be activated by doing the following below options. IMPORTANT: You will need to edit this with another package other than Dreamweaver or you will keep loosing your changes.
[ADVANCED FIND AND REPLACE]
showhiddenoptions=TRUE
ShowHiddenOptions=TRUE
It should now appear again as below but with different icons for 'Save Query' and 'Load Query'.
30 Oct, 2016
03 May, 2017
20 Feb, 2010
I am a Full-stack Developer who also started delving into the world of UX/UI Design a few years back. I blog and tweet to hopefully share a little bit of knowledge that can help others around the web. Thanks for stopping by!
Follow11 Jul, 2023
21 Jun, 2023
Views: 166,096
Views: 40,208
Views: 36,920
Views: 33,515
12 Response
George
12 Sep 2013
Thanks a lot. This helped.
Marianne
13 May 2014
Thank you so much. Adobe DW6 has a bug that creates empty lines every time you format your code (CSS). I couldn't figure out how to remove those from a large style.css. This gem is going into my code library. :-)
me@grafxflow
15 May 2014
Always glad to help.
Jerry Schrader
23 Jul 2014
Thanks! Very helpful
Malik Mudassar
08 Feb 2015
Bring your cheek, I wanna kiss you mate.
me@grafxflow
09 Feb 2015
Glad to help!
Mark Law
12 Mar 2015
Thanks, this is saved me a huge amount of time!
Amin
30 Oct 2015
Give this guy a cookie.... Thanks ...
Surbhi Jain
28 Mar 2016
Thank you so much. it saved my lot's of time :) :) :)
Prasadh
16 May 2016
wonderful... saved me a lot of time :) :) :)
thanks a ton....
Arvind Gondaliya
13 Jun 2018
Not proper work in js file.. Please infom me
me@grafxflow
13 Jun 2018
Hi Arvind,
I have tested this in the latest version of Dreamweaver and it works fine, just a different way of choosing 'Use regular expression' but I have added a new screen shot.
If this doesn't work can you go into more detail with what is happening?