This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 231230 - Pressing ENTER inside string inserts \n\
Summary: Pressing ENTER inside string inserts \n\
Alias: None
Product: javascript
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.4
Hardware: PC Windows 7
: P2 normal with 3 votes (vote)
Assignee: Petr Pisl
Depends on:
Reported: 2013-06-13 15:49 UTC by _ gtzabari
Modified: 2016-12-23 16:57 UTC (History)
0 users

See Also:
Exception Reporter:


Note You need to log in before you can comment on or make changes to this bug.
Description _ gtzabari 2013-06-13 15:49:45 UTC
Product Version: NetBeans IDE Dev (Build 201306072301)
Java: 1.7.0_21; Java HotSpot(TM) 64-Bit Server VM 23.21-b01
Runtime: Java(TM) SE Runtime Environment 1.7.0_21-b11
System: Windows 7 version 6.1 running on amd64; Cp1252; en_CA (nb)
User directory: C:\Users\Gili\AppData\Roaming\NetBeans\dev
Cache directory: C:\Users\Gili\AppData\Local\NetBeans\Cache\dev

I am expecting the same behavior when pressing ENTER with the caret inside a String. In Java,

"foo.|bar" becomes:

"foo." +

where | denotes the caret position.

In Javascript,

"foo.|bar" becomes:


Please make the Javascript editor behave the same as Java.
Comment 1 Petr Hejl 2013-06-25 13:36:00 UTC
Others would oppose that Java does not allow multiline strings while javascript does. So I don't think this should behave the same way.
Comment 2 _ gtzabari 2013-06-26 01:31:15 UTC

This conflicts with my code-formatting configuration that states that long lines should be wrapped. Because Netbeans does not break long Strings, I do it manually, however in the case of multi-line Strings the subsequent line has a different indentation that I'm asking for. Meaning, I'm looking for:

var longLine = "abc123...." +
  "notice the indent of 2";

instead I get:

var longLine = "abc123...\n\
notice the indent of 2";

This is undesirable for two reasons:

1. I'm trying to wrap a single-line string for the sake of readability. Introducing \n means I no longer have a single-line string.

2. I cannot use a continuation indent of 2 as I'd like.

I'd like to propose changing this issue from a DEFECT to an ENHANCEMENT with the following behavior:

1. Either the code-format engine should break long Strings on my behalf (formatting them as I've mentioned above).

2. Or, the code-format engine should contain an option indicating that hitting ENTER should be treated as Java (split a single-line string instead of introducing a multiline string).
Comment 3 Petr Hejl 2013-06-26 06:24:37 UTC
Yep makes sense.
Comment 4 ragamufin 2013-09-19 13:57:24 UTC
I agree. I just ran into this today and would at least appreciate the option to turn it off.
Comment 5 elennaro 2014-10-29 20:02:18 UTC
Vote for an option to turn it on/off.
Comment 6 protasovams 2015-03-13 13:01:52 UTC
+1 for an option to turn it on/off.
Comment 7 adjerbetian 2016-12-07 16:37:06 UTC
Yep, just had this annoying problem, so +1 to turn it off (or as an option).
Comment 8 arnisraido 2016-12-23 16:57:23 UTC