Code Completion with spacebar, any way to disable?

I love the code completion in IntelliJ and I love that it can pre select the first result for you, then just hit enter and continue on your way. however per the documentation both enter and spacebar complete the selected item. is there anyway to make spacebar not complete the selected item and close Code completion and place a space at the curser? I've looked in settings and I have a feeling it's not currently possible.

3 comments
Comment actions Permalink

Just as an FYI, while both enter and space can complete the statement, they do so in different ways. With 'Enter', you cursor ends up inside the parentheses if the selected method takes parameters or just after the parentheses if there are no parameters. With the spacebar, the cursor ends one space after the method regardless if it takes parameters or not. (The third option, Tab, replace any method decalration already existing to the right of the cursor.) For example. completing the method bar(String s)

Enter: foo.bar(|)
Space: foo bar() |

The space bar version is useful when completing method signatures or variable declarations.

That said, I do not believe you can modify that particular key mapping. I did not see an entry for it in the keymap settings. The closest thing to get the behavior you desire would be to turn off the preselction of the first item in the list. (File > Settings > IDE Settings > Editor > Code Completion > "Preselct the first suggestion"). Of course, that only works if you have not arrowed down to select something.The other option, if you did not want to turn off preselction, would be to use the key sequence: Esc, Spacebar

You can open a feature request (http://youtrack.jetbrains.com/issues/IDEA) to make that action mappable.

I hope that helps.

0
Comment actions Permalink

Thanks Mark, I've created the issue http://youtrack.jetbrains.com/issue/IDEA-97183 for anyone else that's interested.


0
Comment actions Permalink

I find that remapping the enter key for acceptance of suggestion a hideously bad idea.  Anything other that 'accept what I got' breaks 50 years of convention and overuses by backspace key- which gets enough use as it is.

0

Please sign in to leave a comment.