Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How import eclipse code style to intellij idea?

Tags:

I have org.eclipse.jdt.core.prefs file, which contains eclipse code style, but I can import to intellij idea only xml files, it there any way import prefs file to intellij idea?

like image 834
roman-v1 Avatar asked Nov 20 '14 09:11

roman-v1


People also ask

How do I import code style into IntelliJ?

Import a scheme Out of the box, IntelliJ IDEA allows you to import settings in the IntelliJ IDEA code style XML or Eclipse XML Profile format. Press Ctrl+Alt+S to open the IDE settings and select Editor | Code Style. and select Import Scheme. Then select the necessary format.

Can I import Eclipse project into IntelliJ?

You can import either an Eclipse workspace or a single Eclipse project. To do this, click Open on the Welcome Screen or select File | Open in the main menu. IntelliJ IDEA automatically detects Eclipse projects located on your computer and places them in the dedicated node right on the Welcome screen.

How do I make my Eclipse look like IntelliJ?

In Eclipse, go to Window->Preferences, and select General->Appearance. You can change the font in there. I don't know what IntelliJ uses, but you can probably look it up in IntelliJ, and just match it.

How do I fix code style in IntelliJ?

In the editor, select a code fragment you want to reformat. Before reformatting, you can take a look at the code style settings that are applied to the selected code: press Alt+Enter and click Adjust code style settings. From the main menu, select Code | Reformat Code or press Ctrl+Alt+L .


1 Answers

Go to Eclipse's Preferences → Java → Code Style → Formatter and export the settings to an XML file via the Export All button (or Edit and then Export in dialog that opens up). Then open IntelliJ IDEA Settings → Code Style → Java, click Manage, and import that XML file by simply clicking Import.

As of IntelliJ IDEA 13, there is no possibility to import .settings/.prefs files directly.


Edit: IntelliJ can import the following Eclipse properties:

  • General
    • Right margin, Formatter on/off tags
    • Indentation
    • Indent size
    • Usage of ‘Tab’ character
    • Usage of Tab only for leading indentation (Smart Tabs)
    • Indent ‘case’ branches from ‘switch’
    • Indent class members
    • Keep comment at first column
  • Spaces (Java)
    • Before/after comma (as set for Eclipse method declaration parameters)
    • After comma in type arguments
    • Within array initializer braces
    • Within brackets (in array reference)
    • Within parentheses of: annotation, ‘for’, ‘if’, ‘catch’ ’while’, ’switch’, method, empty method, parenthesized expression, method call, type cast, ‘synchronized’
    • Before parentheses of: ‘try’, ‘for’, ’while’, ‘switch’, method, ’if’, ‘catch’, method, method call, ‘synchronized’.
    • After type cast
    • Around unary, assignment operators (if it’s set for ‘before’ and ‘after’ in Eclipse).
    • Before opening brace of: array initializer, ‘switch’
    • Before ‘?’ in conditional expression
    • Space before/after ‘:’ in conditional expression
    • Space around binary operators (a single Eclipse setting is mapped to multiple IntelliJ IDEA’s settings)
  • Blank lines
    • Around fields and methods
    • Before/after package
    • Before/after imports
    • Before method body
    • Keep blank lines in code (number of empty lines to preserve)
  • Wrapping
    • New line before: closing brace in array initializer, ‘else’ in ‘if’ statement, ‘finally’ and ‘catch’ in ‘try’ statement, binary operator (if wrapped)
    • New line after: opening brace in array initializer Special ‘else if’ treatment (compact ‘else if’)
    • Keep simple blocks in one line
    • Keep control statements in one line
    • Alignment of: array initializer expressions, arguments in method declarations and calls, field declarations, extends list, assignments, binary expressions, ‘throws’ clause, resources in ‘try’.
    • Brace style for: code blocks, methods and classes
  • JavaDoc
    • Enable JavaDoc formatting
    • Blank lines in JavaDoc
like image 64
user1438038 Avatar answered Oct 06 '22 14:10

user1438038