0

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

lethalMango
  • 4,433
  • 13
  • 54
  • 92
  • Does this answer your question? [How to change the line ending used in Netbeans](https://stackoverflow.com/questions/3294451/how-to-change-the-line-ending-used-in-netbeans) – Shivam Puri Sep 14 '21 at 07:18

2 Answers2

2

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.

  1. 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
  2. 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:

  1. Wiki entry at netbeans.org for line endings

with regards
Tushar Joshi, Nagpur

Community
  • 1
  • 1
Tushar Joshi
  • 2,206
  • 21
  • 20
0

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 :)

Ernest
  • 8,701
  • 5
  • 40
  • 51
  • I have tried that but it didn't solve the issues. I am still left with both the display problem in Netbeans IDE itself as well as it saving incorrectly. Even uploading the file that is saved using NetBeans written fresh causes the issue. – lethalMango Nov 03 '10 at 12:09
  • Just had a google around and found that [\r\n]{2,} to reaplce \n resolves the line issue display in the Netbeans IDE itself, however when saving the file it still saves incorrect in a format I can't upload – lethalMango Nov 03 '10 at 12:14
  • Incorrect format that means what ? Is the file with Lf or CR/LF ? Which one you want ? You can see that in Notepad++ (turn on showing non printable characters) – Ernest Nov 03 '10 at 12:36
  • When I write and save the page in NetBeans, and then upload the file to my FTP, the webserver reads the file as one line (right clicking on the file and then viewing) so I'm guessing that it's an issue with the EOL. I can't work out the cause of the issue. In Dreamweaver it works fine – lethalMango Nov 03 '10 at 13:19