| View previous topic :: View next topic |
| Author |
Message |
saul
Joined: 26 Aug 2010 Posts: 1
|
Posted: Thu Aug 26, 2010 10:59 am Post subject: Configuring line ending style |
|
|
Hi,
I snooped around in configuration settings of Netbean but could not find the subsection for toggling between "CRLF" and "LF". How can I do it? |
|
| Back to top |
|
 |
Bob McConnell Posted via mailing list.
|
Posted: Thu Aug 26, 2010 6:39 pm Post subject: Configuring line ending style |
|
|
From: saul
| Quote: | I snooped around in configuration settings of Netbean but
could not find the subsection for toggling between "CRLF"
and "LF". How can I do it?
|
This question gets asked periodically. The short answer is you can't.
NetBeans uses the line ending that is native to your operating system.
If you have to change it before moving code to another platform, do it
manually. The best way to fix this is to use a source version system
like subversion or GIT which would convert the code when it is checked
in or extracted from the archive.
Bob McConnell |
|
| Back to top |
|
 |
VilaRestal
Joined: 26 Aug 2010 Posts: 16
|
Posted: Thu Aug 26, 2010 6:54 pm Post subject: Re: Configuring line ending style |
|
|
| Bob McConnell wrote: |
NetBeans uses the line ending that is native to your operating system.
Bob McConnell |
I'm using Windows and it certainly doesn't use CRLF.
From what I can gather in the numerous bug reports about it: if you open a file that uses CR or CRLF it will remember that and save using the same format.
Otherwise you're stuck with LF.
Such a simple thing, should be so easy to fix (a couple of tick boxes in the options and an if block in the file saving routine). And so annoying - makes NetBeans files a chore to open anywhere else. |
|
| Back to top |
|
 |
pbw
Joined: 02 Jun 2010 Posts: 23
|
Posted: Fri Aug 27, 2010 1:14 am Post subject: Configuring line ending style |
|
|
Have you created a test class to extract the line.separator property and compare it with \012, \015 and \015\012?
System.getProperty("line.separator")
Peter West
"...do not be faithless, but believing."
On 27/08/2010, at 4:54 AM, VilaRestal wrote:
| Quote: |
Bob McConnell wrote:
| Quote: |
NetBeans uses the line ending that is native to your operating system.
Bob McConnell
|
I'm using Windows and it certainly doesn't use CRLF.
From what I can gather in the numerous bug reports about it: if you open a file that uses CR or CRLF it will remember that and save using the same format.
Otherwise you're stuck with LF.
Such a simple thing, should be so easy to fix (a couple of tick boxes in the options and an if block in the file saving routine). And so annoying - makes NetBeans files a chore to open anywhere else.
|
|
|
| Back to top |
|
 |
Bob McConnell Posted via mailing list.
|
Posted: Fri Aug 27, 2010 12:31 pm Post subject: Configuring line ending style |
|
|
From: VilaRestal
| Quote: | Bob McConnell wrote:
| Quote: |
NetBeans uses the line ending that is native to your operating
|
| system.
| Quote: |
I'm using Windows and it certainly doesn't use CRLF.
From what I can gather in the numerous bug reports about it: if you
open a file that uses CR or CRLF it will remember that and save using
the same format.
Otherwise you're stuck with LF.
Such a simple thing, should be so easy to fix (a couple of tick boxes
in the options and an if block in the file saving routine). And so
annoying - makes NetBeans files a chore to open anywhere else.
|
Interesting, I am using NB 6.8 and it has created some files with LF and
some with CR/LF. It may depend on whether the initial code was cut from
somewhere else or started from a template.
Yes, it can be annoying, because I prefer not to have the extra
character if at all possible. I see no reason to use two characters
where one will do. I have been using TextPad4 which allows you to select
the EOL option when you do a "save as". But I have that configured to
default to the Unix EOL. Then when I use SCP to copy them over to the
Linux servers they don't have to be adjusted. Unfortunately, Perforce
insists on adding the extra character when I extract files. Those I have
to convert after I get them onto the Linux boxen. Thankfully we have
tr(1), but it just makes life more difficult.
However, this has been discussed numerous times before, and the
development team has decided this is the way it is going to be. You will
have to take it up with them on the their mailing list.
Bob McConnell |
|
| Back to top |
|
 |
VilaRestal
Joined: 26 Aug 2010 Posts: 16
|
Posted: Sun Aug 29, 2010 7:21 pm Post subject: Re: Configuring line ending style |
|
|
| pbw wrote: | Have you created a test class to extract the line.separator property and compare it with \012, \015 and \015\012?
System.getProperty("line.separator")
|
LOL, no! And I don't think I'll bother. It would be quicker to uninstall NetBeans.
This is just a small one of many bad design features of it: The terrible form designer (and its generated code) being the worst. And as Bob alludes to: peoples' requests for improvement don't get implemented.
My apologies to all those who have developed it. I know it's free and open source but it's not up to task imho (which is kind of the priority). |
|
| Back to top |
|
 |
pbw
Joined: 02 Jun 2010 Posts: 23
|
Posted: Mon Aug 30, 2010 11:23 am Post subject: Configuring line ending style |
|
|
It's trivial to create a project in NetBeans, and add the required code to main(), run the code, then delete the project. I did it myself in less than 5 minutes. If you do it, you will know exactly what your Java version thinks the line separator is. In your circumstances, I would be curious about that.
Alternatively, if you have bsh.jar on your system,
$ java -jar /path/to/bsh.jar
In the bsh console,
bsh % sep=System.getProperty("line.separator");
bsh % print(sep.equals("\012") ? "LF" : sep.equals("\015") ? "CR" : sep.equals("\015\012") ? "CRLF" : "???");
Peter West
"...do not be faithless, but believing."
On 30/08/2010, at 5:21 AM, VilaRestal wrote:
| Quote: |
pbw wrote:
| Quote: | Have you created a test class to extract the line.separator property and compare it with \012, \015 and \015\012?
System.getProperty("line.separator")
|
LOL, no! And I don't think I'll bother. It would be quicker to uninstall NetBeans.
This is just a small one of many bad design features of it: The terrible form designer (and its generated code) being the worst. And as Bob alludes to: peoples' requests for improvement don't get implemented.
My apologies to all those who have developed it. I know it's free and open source but it's not up to task imho (which is kind of the priority).
|
|
|
| Back to top |
|
 |
VilaRestal
Joined: 26 Aug 2010 Posts: 16
|
Posted: Wed Sep 01, 2010 8:02 am Post subject: |
|
|
Thanks Peter but i do know it uses LF (it's hardly likely to use CR) in the templates so it will always stick with LF in those files. Let me guess: yours is LF too? (and every other NetBeans ever).
There are bug reports about this (going back to the dawn of NetBeans I assume). They just get ignored.
It seems that if the developers themselves don't need a feature they won't bother implementing it no matter how many requests are made or how simple it would be: A days work at the most for 1 of them to add 3 radio buttons to Project Properties that change the default new line ending and find and replace existing file endings.
I'm beginning to see why the GUI editor is so bad (massively over-complicated un-editable designer-generated code + inability to open classes in design that don't have this code): The development process ignores feedback from users.
So, we have a code editor that's worse than many text editors (can't configure line-endings - what else? i wonder) (only benefit over them is a debugger) and a GUI designer that won't design GUIs unless they're its very own unaltered GUIs. (Other java IDEs can do these things quite happily incidentally.)
And no NetBeans admins can be bothered to explain either how I'm wrong (how these things can be done in NetBeans) or to assure people that these issues are being worked on or even just to apologise that people aren't finding it as functional as they had hoped.
I know it's free but, if they're not going to care whether people like it, why bother publishing it in the first place?
But back to the topic: Either I go through all the templates changing all the line endings or never use templates (no more GUI designer) or never use NetBeans.
3 guesses which of them I go for. |
|
| Back to top |
|
 |
pbw
Joined: 02 Jun 2010 Posts: 23
|
Posted: Fri Sep 03, 2010 4:41 pm Post subject: Configuring line ending style |
|
|
Yes, mine is LF, but my point was that it's not NetBeans that is determining that. It's Java. That's why I asked the question. And if Java is assuming the line endings, it's not a trivial matter to override them for certain files. Well-behaved JAVA programs will use the system property when manipulating files, so it's not a day's work - it's a huge can of worms.
(Incidentally I'm surprised that Java on OS X uses LF endings, because I was so used to hearing that Mac used CR endings. However, I find that when I create a text file with TextEdit, I get LF endings, so it must be system-wide.)
Peter West
"...do not be faithless, but believing."
On 01/09/2010, at 6:02 PM, VilaRestal wrote:
| Quote: | Thanks Peter but i do know it uses LF (it's hardly likely to use CR) in the templates so it will always stick with LF in those files. Let me guess: yours is LF too? (and every other NetBeans ever).
There are bug reports about this (going back to the dawn of NetBeans I assume). They just get ignored.
It seems that if the developers themselves don't need a feature they won't bother implementing it no matter how many requests are made or how simple it would be: A days work at the most for 1 of them to add 3 radio buttons to Project Properties that change the default new line ending and find and replace existing file endings.
I'm beginning to see why the GUI editor is so bad (massively over-complicated un-editable designer-generated code + inability to open classes in design that don't have this code): The development process ignores feedback from users.
So, we have a code editor that's worse than many text editors (can't configure line-endings - what else? i wonder) (only benefit over them is a debugger) and a GUI designer that won't design GUIs unless they're its very own unaltered GUIs. (Other java IDEs can do these things quite happily incidentally.)
And no NetBeans admins can be bothered to explain either how I'm wrong (how these things can be done in NetBeans) or to assure people that these issues are being worked on or even just to apologise that people aren't finding it as functional as they had hoped.
I know it's free but, if they're not going to care whether people like it, why bother publishing it in the first place?
But back to the topic: Either I go through all the templates changing all the line endings or never use templates (no more GUI designer) or never use NetBeans.
3 guesses which of them I go for.
|
|
|
| Back to top |
|
 |
digital.discuss
Joined: 13 Jun 2010 Posts: 35
|
Posted: Fri Sep 03, 2010 5:23 pm Post subject: Configuring line ending style |
|
|
Peter B. West mentioned:
| Quote: | (Incidentally I'm surprised that Java on OS X uses LF endings, because I
was so used to hearing that Mac used CR endings. However, I find that
when I create a text file with TextEdit, I get LF endings, so it must be
system-wide.)
|
The now ancient and historic Mac OS used CR ending up to version 9. As a
side note Mac OS hanged around as "classic" inside OS X up to 10.4.
Mac OS X is a totally new OS built on the core of NextStep that Apple
got when they purchased Next in 1996. Mac OS X uses LF endings in most
cases, but sometimes when the OS needs to be backwards-compatible it may
still use CR endings with some technologies - the AppleScript compilers
bytecode spring to mind. /MB |
|
| Back to top |
|
 |
pbw
Joined: 02 Jun 2010 Posts: 23
|
Posted: Fri Sep 03, 2010 9:28 pm Post subject: Configuring line ending style |
|
|
Thanks!
Peter West
"...do not be faithless, but believing."
On 04/09/2010, at 3:23 AM, MB wrote:
| Quote: | Peter B. West mentioned:
| Quote: | (Incidentally I'm surprised that Java on OS X uses LF endings, because I
was so used to hearing that Mac used CR endings. However, I find that
when I create a text file with TextEdit, I get LF endings, so it must be
system-wide.)
|
The now ancient and historic Mac OS used CR ending up to version 9. As a
side note Mac OS hanged around as "classic" inside OS X up to 10.4.
Mac OS X is a totally new OS built on the core of NextStep that Apple
got when they purchased Next in 1996. Mac OS X uses LF endings in most
cases, but sometimes when the OS needs to be backwards-compatible it may
still use CR endings with some technologies - the AppleScript compilers
bytecode spring to mind. /MB
|
|
|
| Back to top |
|
 |
Peter B. West Posted via mailing list.
|
Posted: Fri Sep 03, 2010 10:48 pm Post subject: Configuring line ending style |
|
|
I just tried this in a VM running XP, and the line.separator system property there is CRLF.
Peter West
"...do not be faithless, but believing."
On 03/09/2010, at 12:35 PM, Peter B. West wrote:
| Quote: | | Yes, mine is LF, but my point was that it's not NetBeans that is determining that. It's Java. That's why I asked the question. And if Java is assuming the line endings, it's not a trivial matter to override them for certain files. Well-behaved JAVA programs will use the system property when manipulating files, so it's not a day's work - it's a huge can of worms. |
|
|
| Back to top |
|
 |
VilaRestal
Joined: 26 Aug 2010 Posts: 16
|
Posted: Sat Sep 04, 2010 1:41 pm Post subject: |
|
|
We're talking about the java files!(?) The java compiler or virtual machine is not involved. It is entirely NetBeans choice of line endings without a doubt.
It is because the templates it uses have LF and it uses the same line ending as is originally in the file.
The only way round it is to find and replace all LFs with CRLFs in all templates and all files.
Annoyingly time-consuming process to do what a decent text editor can do. I'd think a decent IDE should be able to do it too but then I'd think a decent IDE should be able to do a lot of things that NetBeans can't. |
|
| Back to top |
|
 |
pbw
Joined: 02 Jun 2010 Posts: 23
|
Posted: Sun Sep 05, 2010 5:02 pm Post subject: Configuring line ending style |
|
|
I think I misread your complaint, I'm sorry.
It's _only_ the templates that are the problem, isn't it? I just tried creating a project in my XP VM, and the lines I added to a file, as expected, had CRLF line endings. However, the template components of the file have LF endings.
What's your bug number?
Peter West
"...do not be faithless, but believing."
On 04/09/2010, at 11:41 PM, VilaRestal wrote:
| Quote: | We're talking about the java files!(?) The java compiler or virtual machine is not involved. It is entirely NetBeans choice of line endings without a doubt.
It is because the templates it uses have LF and it uses the same line ending as is originally in the file.
The only way round it is to find and replace all LFs with CRLFs in all templates and all files.
Annoyingly time-consuming process to do what a decent text editor can do. I'd think a decent IDE should be able to do it too but then I'd think a decent IDE should be able to do a lot of things that NetBeans can't.
|
|
|
| Back to top |
|
 |
Orltean
Joined: 22 Aug 2010 Posts: 8
|
Posted: Sat Sep 11, 2010 9:23 am Post subject: |
|
|
-J-Dline.separator=LF
would force creation of new files in UNIX style |
|
| Back to top |
|
 |
|