I've been using Intellij IDEA, now switched to Eclipse. And I'm looking for an alternative for Ctrl+Shift+Enter in Eclipse which completes the current statement by putting semicolon and goes to the next line. However, when I use this shortcut in Eclipse it goes to the upper line. How can I change the settings to match with Intellij.
I'm using Intellij key schema for Eclipse.
Found an equivalent plugin for eclipse here
https://marketplace.eclipse.org/content/complete-current-statement-eclipse
Only issue I found so far is that it does not obey the code formatting rules. (I like placing curly braces on new line for if statements). Otherwise seems to be similar to the IntelliJ version.
Is this Feature present in Eclipse ( at least even as a plugin will be fine ) . I use Ctrl+Shift+enter in IntelliJ a lot . Some of the things it will do are
if it is normal statement then it will format the current line and add semicolon ( also the cursor position will be end of the line )
if it is a loop/conditional like for,if etc
if -> if ([cursor position]) { } -> if() { [cursor position]}
[ -> means ctrl + shift + enter command ]
If statement is already completed then it will format the current line and goes to next line indented position.
people might think these things are very trivial/not important but only when you try to use this you will find how useful this small feature will be and how much you miss in eclipse .
Related
I just started to learning Node.js and I prefer to use the same IDE (IntelliJ IDEA) that I use for a long time. However, some code completion features does not seem to work.
For example:
In java, when I write something like System.out.println(getName()) and press semicolon when the cursor (|) is on System.out.println(getName()|) it add semicolon at the end of the statement.
However, when I write something in a node project on app.js file console.log(files) and press press semicolon when the cursor (|) is on `console.log(files|), it adds semicolon to the current cursor position instead of at the end of the statement.
So, how can I make IntelliJ to behave as it is on a Java file?
I tried some settings as on the screenshot, but does not make any sende :(
enter image description here
Please vote for WEB-54481 to be notified on any progress with it
Hy all,
In IntelliJ I have set the "Hard wrap at" limit to 100 lines and want all lines that are longer then that to be wrapped by IntelliJ (including Indentation of course) when I reformat the file.
This works for everything except long method names in one of my interfaces (Note: Purple underline is checkstyle which also says its too long):
This alone would not be a huge issue, I can just make a line break myself.
The main issue is, that a manual line break puts the method name on the same indentation level as the method description (which again checkstyle correctly does not like) and when I indent it manually, a reformat of the file moves the line back to this level. So IntelliJs reformat file moves it to the wrong location.
Does somebody have any idea, which setting this is and what I have to change to at least have the correct indentation and at best also the corret wrapping?
Greets
Chris
I'm currently working on an application in Eclipse where I'm running a really huge SQL statement that spans about 20 lines when splitting it in notepad to fit on the screen. Thus I want the string for the query also to be formatted somewhat more readable than a single line. All the time autoformatting normally worked when I used Eclipse but somehow now neither Ctrl + Alt + F nor rightclicking and selecting the "Format" option from the menu doesn't work to get a line break after a certain amount of characters.
I already checked the preferences where I already tried running my own profile with 120 and 100 characters line width but that didn't fix anything so far. I really don't know why Eclipse won't let me format this anymore. Normally Eclipse would be splitting the string into several lines in this case but I don't really know why this doesn't work anymore.
However other formatting is being fixed when executing autoformatting (e.g. if(xyz){ still becomes if (xyz) {.
Thank you for your help in advance.
As far as I can tell, autoformat as you described was never supported (at least as far back as 2008). And I have been using Eclipse much longer than that
You can do one of several things.
Simply insert the cursor in the string and hit a return.
Toggle word wrap Alt-Shift-Y
Try writing a regex to do what you want(not certain if this will work).
A colleague's Eclipse formatting rules cause extreme indentation, and wraps comments to look like this:
// this
// is
// indented
// several
// tabs
They're wrapped at every word boundary because they're indented all the way past the line wrap width. I can reformat them to look only slightly more sane:
// this
// is
// indented
// several
// tabs
but the wrapping remains. Is there any way I can automagically undo this wrapping so that I won't have to spend 30 minutes every time I commit to manually reformat these comments and make the comments readable again? I don't care if other line breaks are not preserved; that would be a reasonable trade. Target result:
// this is indented several tabs
You are not the first to be frustrated by this (me included) I have never found an answer on how to undo this kind of formatting in a great way.
To prevent it happening again, there is of course the option of fixing the formatting rules and then applying them to the project instead of to the workspace. That ensures that if your colleague does format it won't be ruined like this. I recommend setting (in Comments tab of formatter):
turn on Never indent line comments on first column --> this prevents commented out code from being indented and lost
turn off Enable line comment formatting --> this fixes the wrapping problem
Take those settings, followed by using block /* */ comments for actual block comments (instead of what I often see of using line // comments for block comments).
Some other SO users who have posted similar questions with no full resolution, but some suggestions that may help. Such as using a third party formatter (perhaps only once to recover your code state and then continuing as above?)
How to reformat multi-line comments in Eclipse PDT?
Join Lines in Eclipse
I don't think this will be possible with standard IDEs; whilst they're usually good at reflowing lines over the margin, most are reticent to reflow legitimate lines (for good reasons, generally).
That said, I know you do this semi-automatically in IntelliJ IDEA at (sorry haven't used Eclipse for a while but I think it's now possible):
Select the lines with comments and type Ctrl-Shift-J (or equivalent mapping to join lines). This immediately pulls them into one line. Ctrl-Alt-L to reformat that selection if you need to.
It's that or regex I guess.. but be warned...
Try going to Windows -> Preferences -> Java -> Code Style -> Formatter and then click the Edit... button towards the top right under the Active Profile header.
Mess around with the settings in there, specifically the Line Wrapping and Comments tab.
Often times my code does not fit on the same line, I want to place them on the next line to increase readability, but everytime eclipse always create incorrect indent. Is there a way I can ask eclipse to indent properly?
I tried the solution on this question, but it does not seems to do anything for me.
Although you can specify properties such as this in the preferences of the IDE, your indentation preferences are not recommended. The eclipse identations are proper.
Single identations, as you would like, are used to denote the opening of blocks of code such as the following (Curly braces):
if (i = 1) {
//Single identation here
}
Double identation is used for situations such as the following (parenthesis):
System.out.println("This is some string that"
+ " I want to continue on the next line");
In conclusion, you can change it, but Eclipse is actually doing it right to avoid confusion between the two.