How to change eclipse suggestions order and content - eclipse

I installed the Eclipse Neon but feels bad with its code suggestions.
Take the code template as an example, usually I type main and press <ALT> + / to show the suggestions. In the old versions, the main method template shows at the first one. However, the top N is occupied by many Main* class main, it doesn't make sense for me.
Is there any way to change it ?
how to remove any Main* class's suggestions
how to let the code template move to top

Not exactly what you need, but the most approximate solution I know is that you can press CTRL+SPACE repeatedly to browse the content assist list. The first list Eclipse shows is the default proposals. But if you press CTRL+SPACE again and again, Eclipse will show a more specific list each time.
Go to Window > Preferences > Java > Editor > Content assist > Advanced.
The upper list allows you to select (not to sort, sorry!) the contents that will show up as default proposals. This is where you read this unordered, unpractical list of contents. Then, if you press CTRL+SPACE again, Eclipse will show the poposals by categories. The order for these categories to show can be set by the lower list in this window: Content assist cycling.

Don't know if this will be relevant any more, but i ended up here looking exactly for this, and later found out a solution. This might be linked to a specific Eclipse version (i use Oxygen right now)
Go to Window > Preferences > Java > Editor > Content assist and you will find an option that let you select between relevance and alphabetically.

Related

How to get the length of the selected word in the eclipse?

When I am checking the naming rules for my code. If i got variable or function name have more letters than allowed ERROR. I count the total character by manually or have to copy paste into Notpad++. Is there is any options to find the number of selected characters in eclipse.
Eclipse does not provide a way to display the length of a text selection like NotePad++.
Bug 73904: Show length of selection in status box was raised in 2004 (!!!) to add this feature but it still hasn't been implemented.
The good news is that someone has written a plugin named getStringLength to do exactly what you want, as mentioned in a comment in the Eclipse Bug Report:
Eclipse plugin that add the selected text counter on the right side of
the column and row position in the Eclipse status bar. After you
double click the text, this plug-in will show the length of text you
selected in the eclipse status bar; in the case you select more than
one row it will show the number of rows selected, like Notepad++ do.
The bad news is that I couldn't get it to work properly. After adding the plugin to Eclipse's dropins folder the status bar is updated as described, but the details are misaligned and not rendering correctly:
Through careful testing I can see that the plugin actually is updating the length of the selected text, but the entry on the status bar is practically illegible. Still, in the absence of anything else, it is worth trying - perhaps you will have better luck in your environment. Let us know if it works for you.
You don't need a plugin anymore with Eclipse 2019-09:
Editor status line shows more selection details
The status line for Text Editors now shows the cursor position, and when the editor has something selected, shows the number of characters in the selection as well.
This also works in the block selection mode.
These two new additions to the status line can be disabled via the General > Editors > Text Editors preference page.
i has fixed error rendering in eclipse version=4.12.0 on windows 10, with steps.
clone project (getStringLength project)
import to
edit file com.lyf.plugin.getStringLength.SelectedTextInfoControlContribution.java (line 26).
#Override
protected Control createControl(Composite parent) {
parent.getParent().setRedraw(true);
......
}
build plugin:
1. Right-click your plugin project in Package Explorer window.
2. Press Export... in shown context menu.
3. Select Plug-In Development -> Deployable plug-ins and fragments (or Deployable plug-ins and fragments directly in old Eclipses).
4. Close Eclipse. Copy this JAR to eclipse/plugins/ path. Run Eclipse again.
Good luck!

How can I keep Eclipse from filling in auto-completions when I type an opening parenthesis ('(')?

So, on Eclipse Luna, I often encounter the situation where I'm typing a method name, but the first autocomplete suggestion is not the method I am looking for but something that is prefix-equivalent but longer, as in this example:
In the example, I just wanted the element(String name) method, so instead of hitting Return, I type ( instead. The result, quite annoyingly, is this:
This is clearly not what I was looking for. Is there a way to prevent Eclipse from performing auto-complete when I hit open-parenthesis (()?
These are my content assist settings (aparrently, I don't have code recommenders installed at all in this eclipse installation):
In Eclipse 4.11 (2019-03), and possibly earlier, the answer to this is under Preferences → Java → Editor → Content Assist → Disable insertion triggers except 'Enter'. After I checked that box, editing became a lot less annoying.
I have no idea why Eclipse doesn't do it by default. Who types map.put( and wants that to autocomplete to map.compute()?
A hack for this is to change the way Eclipse sorts the proposals.
You can go to Preferences menu and then go to the section for which you want to edit sorting. Then to de Editor section and Content Assist.
For example, for Java editor, it will be Preferences > Java > Editor > Content Assist.
There you will see, more or less in the middle of the window, a section called Sorting and filtering. Inside there is an option called Sort proposalswhich you can change from by relevance to alphabetically. Save an close.
With this you will get the proposals list order alphabetically and element() will be before other methods starting by element.
EDIT:
Tested in Eclipse Luna running in Ubuntu 14.04 and it works. You'll still get your code completed when writing ( but it will be completed with the shorter option available in the proposals list. If you want to use another method, you can continue writing some letters and the shortest option will disapear of proposals as it doesn't match what you are writing.
I guess your problem is the substring matches.
Go Window->Preferences->Java->Editor>Content Assist.
In Sort proposals section uncheck Show substring matches.
I found By relevance more useful then Alphabetically.
I have usually checked hidden Hide proposals not visible in the invocation target, and Hide deprecated references, too.
I hope it help.
The feature you're fighting with is the new "Intelligent code completion" which orders methods based on average usage count. Don't ask me where they get the data. See also here:
http://www.eclipse.org/recommenders/manual/#intelligent-code-completion
To disable the feature go to the preferences page Code Recommenders|Completions and uncheck "Enable intelligent code completion".
Another issue which might negatively affect code completions appears to be 'Java Proposals (Task-Focused)'. For example, it causes map.put() to be replaced with map.compute().
You can disable these from Preferences | Java | Editor | Content Assist | Advanced.
See also: http://literatejava.com/eclipse/bad-auto-completions-in-eclipse/

class view in eclipse

In Eclipse, is there a way to have a Package Explorer like view that shows the classes without having to open the files individually.
I have this project where many classes are written in same files, and that makes navigating them so annoying. Is there some sort of ClassView in Eclipse that disregards file names.
Regards
This question is currently almost 2 years old, but for anyone ending up here through a Google search (like me):
Eclipse offers a "Java Browsing" perspective which is probably what you want. To see this, go to Window -> Open Perspective, and select Java Browsing.
You can use the Outline view.
Window > Show View > Other. Filter by the word 'Outline' (it's under General folder)
window->show view->outline was helpful for me as this was the only window missing in existing perspective.
Yes you can use F3 key if you're seeing this class, o you can use Ctrl+Shift+T shortcut to open 'Open Type' and write in it the name class
Okay, it's been asked a long time ago. You may be looking for the Breadcrumb. Searching for it and got this question. Suddenly I did it unknowingly and shared here. There is a button beside "Save", "Print" buttons; "Toggle Breadcrumb". :)

How to replace Eclipse search dialog?

Is it possible to replace Eclipse search dialog to something more convenient, like the search dialog in Firefox or Chrome? The default one doesn't support F3 to search for the next match, it doesn't move itself away if the match is underneath the box and doesn't allow to highlight all the matches - and these are the features I really miss...
I don't think you can replace the Find dialog easily. You would probable need to (re-)write parts of Eclipse. Definitely doable, but not a small task...
That said, most of your problems can probably be addressed by the current dialog:
The default one doesn't support F3 to search for the next match
"search next match" is Ctrl-K by default. You can configure the keybindings under "Preferences / General / Keys": change the keybinding for "Find Next".
it doesn't move itself away if the match is underneath the box
Yes, that would be nifty. The dialog does however remember where you last put it, so just put it somewhere out of the way (e.g. over the package browser, or to the right), and it will stay there.
and doesn't allow to highlight all the matches
This is not yet available (though it has been discussed: https://bugs.eclipse.org/bugs/show_bug.cgi?id=29692 ). There are however two ways of getting a similar result:
Use the search function from the toolbar ("File Search" from the "torch" button). If you search there, it will highlight all matches in the editor (and provide marks in the editor ruler, and a list in the search view).
For Java elements, activate "Mark Occurences" ("highlight pen" button). This will highlight all occurences of a Java element if you mark in in the editor.
Maybe one of these will help you.
Finally, you can just open any file in an external editor (like (g)vim or Notepad++) right from inside Eclipse (right-click -> Open with). Then you can use any editor you want...
While it may not be exactely what you want, have you ever used the incremental search (Ctrl + J)? In my opinion it is much more convenient than the standard search.
A newer alternative is InstaSearch.
Information:
InstaSearch is an Eclipse plug-in for doing fast text search in the workspace. The search is performed instantly as-you-type and resulting files are displayed in an Eclipse view. It is a lightweight plug-in based on Apache Lucene search engine.
Each file then can be previewed using few most matching and relevant lines. A double-click on the match leads to the matching line in the file.
The "search the next match" is Ctrl-K. Previous is also available, see the "Edit" menu...
Only the highlight feature does not seem to be present. You might need a plugin for that (everythinhg is possible with plugins).
There was a Summer of Code project to implement a Firefox like search in Eclipse in 2007.
This is the official page, and this Blog shows a promising screenshot.
I never tried to install it, and I didn't find a final release or something though :(
SearchTab is an Eclipse plugin that shows a Firefox-like search tab
You do this by changing the key bindings under Preferences -> General -> Keys

Source Editor Tab order in Netbeans 6.5

I recently switched to Netbeans from Eclipse, and the one thing that I liked about Eclipse I'd like to get in Netbeans:
The order of the tabs at the top of the Source Editor in Eclipse seems to be related to most recently used, so if I have a group of 5 files I'm working on at one time, they are all likely to be visible in the tab list, no matter how many tabs I have open.
In Netbeans, this isn't the case - I don't know what the order is, but it isn't useful for switching between my active files quickly - its usually faster to re-open the file to switch to the correct tab than to actually use the tab system.
Is there an option setting or a plugin that can change this behavior to something more like Eclipse?
By default the tabs in NetBeans are ordered acording to when they were opened. I don't think there's a way how to change it right in NetBeans and don't know about any plugin neither. I think this behaviour is just a matter of taste - I was used to NetBeans behaviour and when I'm using Eclipse, I always get confused about shuffled tabs. But as Kevin said you can drag the tabs to change their order.
When you press CTRL + TAB, the documents in the popup window are ordered acording to last used. This might be usefull for you.
Another (partial) solution might be docking a documents window (Window -> Documents) which contains opened documents and where documents are ordered alphabetically. It's better than re-openenig the files (as you wrote) especially if youre files are spread in different packages and you can't see them in projects/files view on one screen.
I don't think it does. However, you can drag the tabs to the positions you want them in. I would suggest just ordering by your liking manually.