Within our team, we have an eclipse formatter profile that we are using for some years. It seemed to work fine within Eclipse Neon, but today I discovered that the formatter is no longer "trimming" empty lines.
When using older versions of eclipse, running the formatter simply trims lines that only contain spaces. The line is still there, but the spaces are all gone after formatting.
I checked the formatter options; but I can't find a checkbox that would match.
For the record: I saw this, but using "trim on save" is a no go for me: very often I have to make subtle changes in files from other people; and I intentionally do not format those files; because the diff would be huge. And for the same reason, I don't want that "save" trims empty lines either. Before Neon, I would press ctrl-f on purpose; also to trim lines; now it doesn't have that effect any more.
Any idea where to fix that?
As the answer says in the linked question, you could do on save for only lines you have changed
Removing whitespace only from the lines I changed:
Preferences -> Java -> Editor -> Save Actions -> check "Perform the selected actions on save" -> check "Format source code" -> select "Format edited lines".
Related
How can I get rid of empty lines between imports of different 'Import-groups' with code formatting in Android-Studio? (want delete line 9 and 12)
With File ->Settings -> Default Settings -> Editor -> Code Style -> Java: set Blank Lines to 0 it doesn't work.
Both not work:
How to remove unnecessary blank line on code formatting in Android Studio
How to remove unnecessary blank line on code formatting in IntelliJ?
Using Android Studio 3.4.
The "Blank" lines section is for spaces in the code file, but the Imports section has a dedicated tab in Android studio.
Have you played around with these? Does it do what you need?
It's worth noting that the "default convention" consists of separating packages like so, so unless you have a very valid reason (spacing is not a good one, because you can collapse them by default), I wouldn't bother with that.
I am facing a weird issue in IntelliJ that whenever I entered double quotes it will automatically converted into either 3 double quotes or sometimes it is converted to some Unicode letters.
For example, if I enter A after " then the text would change into something shown in the image.
I am using macOS 10.13 High Sierra. Thanks in advance
I had the same issue and the problem was not in IntelliJ IDEA but in keyboard input source on MacOS.
The reason of issue: I was using "U.S. International - PC" keyboard on MacOS. When I changed it to "U.S." the issue was gone.
Steps to solve the issue:
Go to System Preferences -> Keyboard -> Input Source tab
Click on + button -> add "U.S." input source (or "British")
The default behaviour of IntelliJ IDEA is to saving you time by inserting a pair of quotes when you type the opening quote. This is controlled by Settings -> Editor -> General -> Smart Keys.
The funny characters appearing in your case may be due to some weird setting. Try going to Settings -> Keymap.
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.
Could anybody share their eclipse formatter settings file or point me to such a file which will prevent my eclipse from doing the following thing:
when I press ctrl+shift+F to format my code, eclipse from this string:
dayArrayList.add(new Day(WeekDay.SATURDAY));
the following string:
dayArrayList.
add(new Day
(WeekDay.SATURDAY));
So I want only really looooooooooong code strings be moved to next line (those, which don't fit into the eclipse window), but eclipse do this almost with all strings.
Thanks in advance!
Simply increase the Maximum line width to let's say 140 chars?
The following formatter does this.
In Eclipse go to Window->Preferences->Java->Code Style->Formatter
Then Create a new profile and in the Line Weapping Tab you have the Parameter "Maximum line width"
You can set the maximum line width in eclipse by:
Window -> Preferences -> Java -> Code style -> Formatter -> Edit
On line wrapping tab, change the default 80 to your preference. Note that you will have to save as a new profile if you are changing the default one.
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.