Eclipse JavaScript formatter is crazy (i.e. Too many add-ons)

I'm having trouble getting the eclipse format well. In this first example, it behaves as expected (not the length of the second URL):

Behaving good

Whenever I have a longer url, eclipse is crazy about formatting my code, and I get extra padding everywhere, as shown below:

Behaving bad

Why does the JavaScript engine work like this and how to fix it?

(Just in case: I did not install the formatting plugin, I just use the default value that comes with Eclipse Juno)

+5
source share
3 answers

The long URL in the example affects "$ .ajax (..." and "$ (function () ...".

"$ (function()...", /JavaScript/Code Style/Formatter/Line Wrapping/Function Calls/Arguments. "Do not wrap" .

"$.ajax(...", " " Java. (/ Java/Code/Formatter/Line Wrapping/Function Calls) , JSDT . (/JavaScript/Code Style/Formatter/Line Wrapping/Function Calls)

JSDT 1.4.1 (WTP R3.4.1).

  • Eclipse
  • // JavaScript/
  • ""
  • , , "Eclipse []" ( JavaScript) , " " ( ) ""
  • Eclipse

  • workspace/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.jsdt.core.prefs
  • 16 0
    org.eclipse.wst.jsdt.core.formatter.alignment_for_selector_in_method_invocation=16
  • Eclipse

( , , 1-5 )

, . - ( , , , , XML "org.eclipse.wst.jsdt.core.formatter.alignment_for_selector_in_method_invocation" 0. reimport . .

, , - ( ), .

+10

Preferences > JavaScript > Code Style > Formatter

:

  • ( ), , Edit....
  • Line Wrapping.
  • Maximum line width 9999.
  • Apply Ok.

, 9999 , .

+11

:

  • Window -> Preferences -> JavaScript -> Code Style -> Formatter

  • JavaScript.

  • Edit

  • Indentation Tab policy .

  • Indentation size, Tab size 3.

  • , .

  • Press Ctrl+ Shift+ Fand enjoy.

NOTE: I don't like having 3 spaces, I would prefer my good old 4 spaces, but this is a temporary solution until someone finds a better way to solve this problem. I just enjoyed sharing.

+1
source

All Articles