问题
Issue 1
I have been using NetBeans on my work machine to develop a PHP website. The issue I have is that using netbeans, in the application itself, every other line is a blank line. Even opening a correctly formatted document will cause this issue. E.g.:
Coded using Notepad:
<p>
Test para with
just a standard line break
and just a few more to
show what I mean</p>
When displayed in NetBeans is shows as:
<p>
Test para with
just a standard line break
and just a few more to
show what I mean</p>
Issue 2
The main issue I have, is that all files saved are saved in a single line (proven when opened in notepad). This causes me an issue when uploading as it reads the PHP files in a single line so the first comment will cause the rest of the document to be commended:
<?php[]include('lib/config.php');[][]$query = "SELECT * FROM......"[][]// This comment now comments out the rest of the document>
The [] represent the square boxes shown in the notepad file.
I have tried all the formatting settings in NetBeans for PHP but I can't seem to resolve it.
Thanks
回答1:
This question got answered in one way on an old StackOverflow question here.
To change the way how NetBeans IDE editor save your line endings, you can follow the following instruction.
- Open the NetBeans Configuration file from NETBEANS_HOME\etc\netbeans.conf where NETBEANS_HOME is the folder where NetBeans IDE is installed, which is usually C:\Program Files\NetBeans IDE 6.9.1 (may change according to your version) in Windows
- Update the setting netbeans_default_options and add -J-Dline.separator=CRLF at the end of it.
For example:
netbeans_default_options="...... -J-Dline.separator=CRLF"
--where ....... means existing settings which we have to keep as they are.
References:
- Wiki entry at netbeans.org for line endings
with regards
Tushar Joshi, Nagpur
回答2:
Notepad uses windows line end style - CR/LF (\r\n), while Netbeans for some reason, opens a file in Linux style (\n). To fix this you can:
- stop using a Notepad, and use f.i. Notepad++ - where you can configure line ending style. (notepad can't understand LF - so displays it as squares)
- convert your documents to one chosen style - I always force my software (editors, git, ect) to use LF only. You can do this with NetBeans:
- Ctrl+Shift+H (opens Replace in projects window)
- Containing text: \r
- Replace with: nothing, leave this blank
- tick Regular Expression
- find and replace
Backup your data before doing this :)
来源:https://stackoverflow.com/questions/4086750/netbeans-saves-code-incorrectly-all-on-one-line-with-squares-where-the-line-bre