I have this line showing the problem:
Which setting in the Eclipse Java formatter do I have to change so the line will break like
return this.data.getNumberOfGenerationsWithoutSignificantImprovementPassed()
> MAX_NUMBER_OF_GENERATIONS_WITHOUT_SIGNIFICANT_IMPROVEMENT;
or like
return this.data.getNumberOfGenerationsWithoutSignificantImprovementPassed() >
MAX_NUMBER_OF_GENERATIONS_WITHOUT_SIGNIFICANT_IMPROVEMENT;
? If both is possible, I prefer the former.
On Mac, go to Eclipse -> preferences. On Windows, I believe it is Windows -> preferences... but don't quote me on that!
Expand Java -> Code Style -> Formatter
To the right of the "Active profile" bar, choose edit.
A new window will open- choose the "Line Wrapping" tab.
Scroll down to "Expressions" and choose conditionals. Pick your favorite!
Bonus points: This is where you can set all sorts of different styles, if you have not before, like number of spaces per tab character. Once you get everything set up just right, name your profile and export it. I use the same theme on 3 different computers and the consistency is nice!
Related
I noticed with the new IntelliJ update, that it turns symbols like >= into the actual math greater than or equal to sign, along with arrows (->) and things like that. How do i turn this feature off and just get the raw characters.
Thank you
It seems like whatever font you are using supports ligatures, and IntelliJ is set to render them too.
To change the settings, first go to "File > Settings" and then select "Editor > Font" tab:
Either:
select a font that doesn't have ligatures, or;
uncheck "Enable font ligatures"
I want the values of two (or more) arrays to be lined up like in the bottom row of this example.
Is there a way to do this in Eclipse?
You can switch off Eclipse formatter (see https://stackoverflow.com/a/3353765/5277820) and format the lines by yourself.
If I misunderstood your question I apologize, I assume you are talking about the formatting in Eclipse.
(Windows version)
In Eclipse, go to
Window -> Preferences -> Java -> Code Style -> Formatter.
Open the profile (should be default, but I'd suggest creating your own)
In the Line Wrapping tab, there is a "Maximum Line Width" that you can change (default is 80). That will prevent lots of these automatic line wrappings.
See the image below. For the white spaces you need to navigate to the "White Space" tab.
Eclipse code-formatting options are vast (see Java -> CodeStyle -> code formatting)
What I want is to avoid that the autoindent split my lines of code in 2 (or more) lines (see below). When reading-debugging code, is far more clear to read complete lines (IMHO)
Ex
float vsleep = (float) (((nodelenght) * obj
.getFactorperchar()) * 1000);
If I understand correctly, you want to stop eclipse from wrapping text over one or more lines.
If you navigate to Window -> Preferences -> Java -> Code Style -> Formatter and then click "Edit" next to the active profile, you can edit all of the auto formatting options. Choose the Line Wrapping tab, and then select all of the options in the list that contains "Class Declarations", "Constructor Declarations" and so on. Underneath the list, set the Line wrapping policy to "Do not wrap".
I tested this in my version and it seems to work.
Try setting Line Wrapping -> Maximum line width to something larger.
I'm using Checkstyle for Java in Eclipse IDE. I don't know in every java file, at second line, I always receive warning in Checkstyle : (although I'm pretty sure that I don't press tab key)
File contains tab characters (this is the first instance).
public class Percolation {
private boolean[][] grid;
...
}
When I have typed : public class Percolation {, press enter, Eclipse will make an indent for me, after that, I type private boolean[][] grid;. But, I still receive this warning.
Please tell me how to fix this. (I don't want to turn off this warning, because this is a must. Another people will check again my file).
Thanks :)
step 1 In eclipse, Preference > Java > Code Style > Formatter. Edit the Active profile.(If you don't wish to edit the built-in profile , create a new profile). Under "Active profile:" there is a drop down dialogue box .. beside it, click "Edit..." which opens up the edit dialog box. Under the "Indention" tab, you'll find Tab Policy. Change the Tab Policy from Mixed to Space only & apply the changes.
step 2 Back to your Eclipse Perspective, navigate via the menu bar: Source > Format Element (not "Format") and save.
Run checkstyle you won't find "File Tab Character: File contains tab characters (this is the first instance)." warning anymore.
To visualize the difference by enabling whitespace character that you'll find in tool bar.
In eclipse, go to Preferences > General > Editors > Text Editors
and check the box for "Insert spaces for tabs". Then it will indent with spaces instead of tabs.
another possibility is find and replace:
- copy a tab
- Got to Find and Replace Window
find: paste the tab
replace: type 4 whitespaces (or number of whitespaces a tab consists of)
-> replaceAll
For Java code:
step 1 In eclipse, Preference > Java > Code Style > Formatter. Create a new profile and initialize it with default profile. There is a drop down dialogue box .. beside it, click "Edit..." which opens up the edit dialog box. Under the "Indention" tab, you'll find Tab Policy. Change the Tab Policy from Mixed to "Space only" & apply the changes.
step 2 Correct Indentation of your code by ctrl+I. It will replace Tab with Space.
To fix this Navigate to Preferences > Java > Code Style > Formatter.
Then click on New > give name for the formatter > click on ok.
Once you complete this step, on the automatically popped up window which is the formatter you created, click on indentation > tap policy > select space only.
Or if you come back later time you could click on edit and follow the same step.
in the indentation size I prefer to put 4 > click apply and close.
After that right click on the class file you want to format > source > format.
This will cause the indentation to be spaces instead of tabs.
I was also facing the problem but I got the solutions.
Step 1 : Go to Window > Preferences > Checkstyle.
Step 2 : In the right side You will see the Global Check Configurations. There you will find that Two configurations are available. Select the configuration with Eclipse and click on Set as Default button and click on OK.
Hope this will solve your problem.
For Java Editor
Click Window » Preferences
Expand Java » Code Style
Click Formatter
Click the Edit button
Click the Indentation tab
Under General Settings, set Tab policy to: Spaces only
Click OK ad nauseum to apply the changes.
For other editors refer here How do I change Eclipse to use spaces instead of tabs?
Simply fixed that style issue (triggered by scalaStyle) by removing TAB with SPACE indent :)
I use Eclipse IDE and Window Builder Pro for create window.
When I go to the source code I see a big indent text. How to delete ?
How about good old Shift + Tab?
If by "how to delete" you mean to say that you want to decrease the indentation level, try this:
Go to
Window->Preferences->general->Editors->Text
Editors
There specify the indentation level under :
Displayed Tab Width.
Additionally you can customize you formatting in Eclipse as :
Go to
Window->Preferences->Java->Code
Style->Formatter
Select the formatter and press Edit. Use whatever suits you.
Then Select the text you want to format and press Ctrl+Shift+F
If you want to fix indent only you can select lines and press Ctrl-I.
Take a look at Eclipse keys
Most likely you insert tab character which is being expanded to 8 positions in target IDE.
Change setting in Eclipse to insert 4 spaces (or whatever your style is) when tab is pressed.
Then you can try to reformat your file in Eclipse. Also, you can use sed to replace \t with 4 spaces.
If you like the way your formatter is set up for the rest of your code, perhaps telling the formatter not to work on this section would be desirable. Then you can unindent the section to make it visually appealing and not worry about it changing formatting.
Linked solution works in Eclipse 3.6.