How to change the line ending used in Netbeans
Asked Answered
D

6

23

Netbeans has this wiki entry on line endings: http://wiki.netbeans.org/FaqEditorEOLs

But it isn't very useful. It just says that you shouldn't develop on different OS and that's that...

In my situation however, I have no power over it. I'm on a windows machine and the PHP app I'm working on needs to end with the UNIX EOL.

There does not seem to be an option to set this for new files. Can anyone tell me where to set this?

Dwaindwaine answered 20/7, 2010 at 21:20 Comment(0)
M
14

Just saw that you can set this as a command-line startup flag: -J-Dline.separator=LF

I haven't tested this myself but I'm looking for ways to bake this into the configs somehow.

Mountford answered 23/7, 2010 at 19:51 Comment(3)
-J-Dline.separator=LF does not work for me, instead it prints the letters L and F into files where the line endings would be (NetBeans 8.0.2) btw why is there still not an option for this?Grotto
WARNING!!! It also prints L and F into configuration files! I just destroyed all my settings ...Grotto
Netbeans 8.2 - something is broken now.Catalyze
V
13

Since, a specific plug-in came out: http://plugins.netbeans.org/PluginPortal/faces/PluginDetailPage.jsp?pluginid=36810

I also like @JimLewis suggestion but I work on Windows with a linux virtual machine thus in some cases the versioning system line ending cannot help.

[update 201709]

I no longer use netbeans (sorry, but I need python support and it's too buggy) and almost no longer develop on windows, but @marinos-an in a comment suggests https://github.com/welovecoding/editorconfig-netbeans which uses a common setting file that can be picked up by multiple editors through plugins. Definitely interesting to try since the settings file is committable!

Viipuri answered 15/11, 2011 at 14:4 Comment(5)
This plugin works perfectly - it adds the current setting to the status bar and allow you to change by clicking on itCodycoe
...and by the way, my current experience with line ending on the borderline world of windows with a linux virtual machine is that it's better to force LF everywhere. Windows knows how to deal with it, in any case (beside notepad that shouldn't even exist).Viipuri
This is an important issue, I really can't figure out why such a feature is not implemented natively into Netbeans. It's not that hard to do and it's very useful. The plugin works perfectly, btw, thanks.Jeepers
This plugin github.com/welovecoding/editorconfig-netbeans may be even more useful, since it can be used to force line-ending rules, and supports a kind of standardized committable format: editorconfig.org (which has a wide editor support: github.com/editorconfig).Coinsure
I confirm it is working fine for Netbeans 8.2 (development version Build 201804200002 )Catalyze
F
11

Have you considered managing the line endings at the version control level? Subversion, for example, lets you set an "eol-style" attribute with values "LF", "CR", "CRLF", and "native" (which translates the line endings stored in the repository to whatever is appropriate for the platform where the files are being checked out, and converts the other way when you check in.)

Falsetto answered 20/7, 2010 at 21:47 Comment(3)
The OP did not say anything about using version control software, but I do agree with setting this property in a .gitattributes file or whatever it is for your VCS.Calomel
+1 ... and simple procedure for git: help.github.com/articles/dealing-with-line-endingsMeredeth
@Calomel Netbeans does not seem to correctly support .gitattributes. It uses JGit behind the scenes: bugs.eclipse.org/bugs/show_bug.cgi?id=342372 (chaotic) . I has struggling to findout why some sometimes newlines were added as CRLF and sometimes they weren't. It depended on whether Netbeans was used to add the files or the git cli.Coinsure
T
2

Please use following Netbeans Plugin

http://plugins.netbeans.org/plugin/36810/show-and-change-line-endings

Tannin answered 23/10, 2012 at 9:10 Comment(1)
that's exactly my answer https://mcmap.net/q/560237/-how-to-change-the-line-ending-used-in-netbeans, just one year later...Viipuri
L
2

fentie's answer solved my problem with line endings, as pasting multi-line MySQL from NetBeans into the MySQL command prompt caused errors.

To pass this argument to NetBeans every time it opens, add it to the netbeans.conf file:

/Applications/NetBeans/NetBeans\ 7.1.2.app/Contents/Resources/NetBeans/etc/netbeans.conf on OS X.

From the NetBeans Mac page under Tips & Tricks.

When I pasted multi-line SQL statements from NetBeans to the MySQL command line client on OS X or a remote Linux server, MySQL would list all possible command choices, give me some strange '> type of prompt and I was forced to hit Ctrl+C and log back into MySQL again.

Languorous answered 10/8, 2013 at 16:52 Comment(1)
My Windows 7 path: C:\Program Files\NetBeans 7.3.1\etc\netbeans.confAdaline
C
1

For my Netbeans 12.6

I found a pluging called "Change Line Endings on Save"

https://plugins.netbeans.apache.org/catalogue/?id=31

more details are there

https://github.com/junichi11/netbeans-change-lf

once pluging installed you can configure EOL in there:

Tools > Options > Editor > Line Endings

Catalyze answered 25/3, 2022 at 1:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.