Change hotkey for autocomplete selection

跟風遠走 提交于 2019-12-03 16:41:21

问题


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.


回答1:


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.




回答2:


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




回答3:


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).




回答4:


If you have a Mac, you can download the Better Touch Tool(BTT) and change the hotkey to tab. Just tried and it worked, however if you do this you can't use the tab-key to tab regularly with the text. Which is pretty good to be able to bo. I changed it to shift+space.

In BTT, select Keybord in the menu between Trackpads and Apple remote. Add eclipse with the + sign on the left side. Then press +Add new shortcut. In keybord shortcut press the hotkey or combination you want. In Trigger Other keybord Shortkey press ctrl+space and you are done! Just be sure that the new shortcut is enabled in the right corner.

http://www.bettertouchtool.net/



来源:https://stackoverflow.com/questions/3663015/change-hotkey-for-autocomplete-selection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!