Solved

fix source code in dreamweaver that is double spaced

Posted on 2009-07-01
16
625 Views
Last Modified: 2012-05-07
I have some scripts that keep getting double spaced due to someone elses FTP program. I have asked them to stop using it but it's already affected many files and it's too late to go back into the old versions of the code because we've committed these spaces to our repository due to time restrictions.

How can I single space the file easily in dreamweaver. I'm willing to use another utility if necessary.
0
Comment
Question by:MeridianManagement
  • 6
  • 5
  • 3
  • +2
16 Comments
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 24757752
Hi MeridianManagement,

You can do Commands | Apply Source Formatting to fix excessive whitespace.
0
 
LVL 2

Author Comment

by:MeridianManagement
ID: 24757761
doesn't seem to fix php...
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 24757809
Hmph, it apparently doesn't.  Are these pages just PHP code or mixed PHP and HTML?

0
 
LVL 2

Author Comment

by:MeridianManagement
ID: 24757813
mixed. There is also a lot of javascript files with the same issue.
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 24757856
Okay.

The reason this happened is that the other user has a different line-break method set than you do.    DW probably isn't the best tool for this because you would need to run a Find and Replace on two blank lines in Source Code mode and I can see that not working as expected.

Go grab NotePad++ as it has an option to remove blank lines under its TextFX | TextFX Edit menu.
0
 
LVL 2

Author Comment

by:MeridianManagement
ID: 24757883
Thanks Jason,

That's definitely a pretty close solution. I was hoping it would be possible to only replace every other line (not everyone empty line), because technically there are some line breaks for a reason. If you can think of anything let me know
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 24757931
You can apply the Notepad++ solution selectively.  So highlight the code that has the excessive line breaks and apply the TextFX.  It will only remove the line breaks from the selected area.
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 24758952
MeridianManagement,

This might be something where a Regex could help too.  Does Notepad++ support those for a replace?   Can you provide a sample file so I can make sure I understand how the file is affected?  If Notepad++ won't work with a Regex then there are other programs that will although I am not sure of free ones that you can use.  I believe there are some but I would have to verify first.

The PSPad editor has a number of features too so it might also have an option to strip the extra lines and not be bothered by PHP.  Let me know if you want me to test and verify this but a sample file will help this.

Let me know if you have any questions or need more information.

b0lsc0tt
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 24758960
b0lsc0tt,

Good points.  NotePad++ does support regex, as does DW but DW's regex interpreter is a little limited.

0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 24759017
If so, and without a sample to be sure, then you would need some a regex like the following for the test ...
\r\n\r\n
... and then in the replace you just provide a line break (i.e. hit the Enter key probably although I can provide characters if the program can convert them).
The thing I don't know for sure is if the file that is being read wrong actually has a carriage return and a new line character or just the new line character.  Most likely the former.  I have seen files "messed up" like this before but never bothered to spend the time to see why or try to fix them.  Homesite just corrects them in the display but it is annoying to have them messed up.
A sample will really help.  Also if you have a question trying to use the above then let me know about the program and choices you see.
bol
0
 
LVL 5

Expert Comment

by:Opalelement
ID: 24760943
If you replace two newlines with one newline in dreamweaver find&replace, it should only take out every other line
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 24765420
Opalelement,

That may or may not work as expected.  If another user opens the file in a different editor you may get different types of line breaks.  That's why b0lsc0tt suggested regex and I suggested Notepad++ because those options can handle \n\n \n\r or \r\n depending on how the other editor threw those in.  DW will handle a blank line in Find and Replace differently depending on which line break type is chosen in the options.
0
 
LVL 2

Author Comment

by:MeridianManagement
ID: 24766001
okay here's an example of a file. It was partially fixed in dreamweaver that's why some of the file looks okay.
0
 
LVL 2

Author Comment

by:MeridianManagement
ID: 24766022
Here you go, it didn't like the php extension
property-display.txt
0
 
LVL 54

Accepted Solution

by:
b0lsc0tt earned 500 total points
ID: 24766189
It is the \r\n that is used (i.e. a carriage return followed by the new line character).  In the match field (or its equivalent) use ...
\r\n\r\n
... and in the replace field you would either place ...
\r\n
... or just press Enter.  Now that will get rid of every occurence, except 4 in the case of your file above.  In that file it looks like 4 lines already had the double space so they actually have 3 line breaks now.  You could run it again if you want to get rid of them all but maybe you want to keep those.
Let me know how it works.  If Dreamweaver has a problem then I used a program called EditPad (actually the Pro version) to run it and it worked.  Let us know if you have a question.
bol
0
 

Expert Comment

by:m_abdelfattah
ID: 25290639
This should be the solution :
1. Open Dreamweaver Preferences ( Edit -> Preferences ).
2. Select Code Format
3. Change Line break type to LF (UNIX)
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses how to create an extensible mechanism for linked drop downs.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now