Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » JavaScript editor: return key does not insert newline after opening square bracket, inserts spaces
JavaScript editor: return key does not insert newline after opening square bracket, inserts spaces [message #984596] Wed, 14 November 2012 15:51 Go to next message
Ben Johnson is currently offline Ben Johnson
Messages: 15
Registered: March 2012
Junior Member
All I want to do is type

var myArray = [


and then hit the Enter key to insert a blank line and indent the cursor one tab, yielding the following:

var myArray = [
	| <--- pipe position represents cursor (indented one tab)
]


Instead, when I hit the Enter key, Eclipse moves the cursor to the right of the closing square bracket. (I realize that I can disable this aspect under Preferences -> JavaScript -> Editor -> Typing -> Automatically close.) If I then left-arrow back, such that the cursor is between the square brackets, e.g., [|] (the pipe character represents the cursor), and again hit Enter, Eclipse inserts only one newline (when I want two), but it also inserts enough spaces to bring the closing bracket inline with the opening bracket on the line above, like so:

var myArray = [
               ]


How is this useful?

Eclipse exhibits exactly the behavior that I want if I use curly-braces instead of square brackets.

So, is there any way to force Eclipse to handle square brackets exactly as it handles curly braces?

I have tried creating a custom JavaScript code template (in Preferences -> JavaScript -> Editor -> Templates), and I even unchecked "Use Formatter" for the template, but Eclipse still applies this questionable formatting to the block.

Thanks for any help here.
Re: JavaScript editor: return key does not insert newline after opening square bracket, inserts spac [message #984646 is a reply to message #984596] Wed, 14 November 2012 16:47 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan Herrmann
Messages: 927
Registered: July 2009
Senior Member
You may want to look for a forum related to JavaScript, JDT doesn't provide the JavaScript editor.
Re: JavaScript editor: return key does not insert newline after opening square bracket, inserts spac [message #994365 is a reply to message #984646] Thu, 27 December 2012 00:17 Go to previous message
rob montgomery is currently offline rob montgomery
Messages: 11
Registered: July 2012
Junior Member
The javascript language in Eclipse is supported under the JavaScript Development Tools group (JSDT) http://www.eclipse.org/webtools/jsdt/ , however, I also cannot find the support forum for javascript.
Previous Topic:jdt latest version ??
Next Topic:how to use IViewActionDelegate?
Goto Forum:
  


Current Time: Mon Apr 21 08:42:07 EDT 2014

Powered by FUDForum. Page generated in 0.01910 seconds