Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change hotkey for autocomplete selection

In Eclipse, I find it pretty annoying that Enter is the hotkey that selects an item from the Content Assist/Autocomplete list. Especially in PyDev where there is no end-of-line semicolon, pressing enter for a new line will instead give me whatever is selected in the Autocomplete list.

Tab is a much better selection hotkey since I'm not likely to want a tab mid-line.

Any chance of changing this in Eclipse?

Using CDT, PDT, and PyDev, but interested in any solution related to Eclipse.

like image 594
ack Avatar asked Sep 07 '10 21:09

ack


3 Answers

All key bindings in Eclipse are defined in Window -> Preferences -> General -> Keys. I don't think you can change what is used to select stuff from the autocomplete list, but you can use space to select and then Enter for new line.

like image 68
TK Gospodinov Avatar answered Nov 06 '22 18:11

TK Gospodinov


The autocompletion selection key(s) is editor specific. For instance in Aptana Studio, you could define set of keys for proposal selection. See e.g. Preferences/Aptana Studio/Editors/JavaScript. Since PyDev shares some code with Aptana Studio, it has similar capabilities. See "Preferences/PyDev/Editor/Code Completion/Apply completion on *" checkboxes.

Speaking of the Tab key as a selector, it doesn't seem possible w/o extra coding since it has special meaning to focus into proposals window. For these who interested could find Tab handling at org.eclipse.jface.text.contentassist.CompletionProposalPopup.verifyKey(VerifyEvent)

Cheers, Max

like image 31
Max Avatar answered Nov 06 '22 19:11

Max


Unfortunately it's not really possible to use tab instead of enter to auto-complete in PyDev (nor in Eclipse itself).

So, what I do in these cases is use Shift-Enter to go to a new line: note that in this case, you can press Shift+Enter from any place in your line and it'll mimic a 'go to end of line, press enter' (which is a nice thing for me).

Implementation note: as Max pointed out, the '\t' and '\r,'\n' cases are actually hard-coded in Eclipse at: org.eclipse.jface.text.contentassist.CompletionProposalPopup.verifyKey(VerifyEvent) so, to fix that, you'd need a patch which changed that at Eclipse itself (so, if you feel it's worthwhile, create a bug-request in Eclipse itself to ask for that feature).

like image 1
Fabio Zadrozny Avatar answered Nov 06 '22 18:11

Fabio Zadrozny