[Solved] Pycharm doesn't auto complete basic statements e.g. "for", "while", "if" etc.

I am using Pycharm Professional on 2019.1.1 on a Linux Machine

I notice that it's funny that when trying to auto complete the most basic statements like "for", "while", "if" etc. Pycharm is NOT auto-completing the statement. There are many other auto-completion statement though, but for those very basic ones, when the auto-completion suggestion list popped up, there is no any brackets, colon or semicolon etc. presented after the "for", "while" or "if" statement's suggestion. 

Could anyone help explain what is wrong with this Pycharm, and how to fix it?



Comment actions Permalink


I have a hard time imagining what do you expect to be autocompleted. Let's take for example:

for i in range(10):

What do you expect to be autocompleted here? the ":" character? Please give some examples.

Comment actions Permalink

@Andrey Resler

For example, when you type “fo”, you could use auto complete to make “for “ (this part has no issue on Pycharm). Then when typing “i in ran” the auto complete could complete this to make it into “for i in range( )” (this part also has no issue). But once we type what’s inside the range parentheses, “for i in range(10 )” the caret is right now still inside the prarentheses of range, so we we hope the auto complete could do is to: auto complete the the colon at the end and automatically make an indentation at the second line, move the right after the indentation on the second line once after we hit the meta-ctrl-enter (shortcut on Linux Pycharm), such that I could start typing “print…” from where it should be. But the problem here on the Linux machine is that when I’m in “for i in range(10 )” and hit the shortcuts, it will move to second line and make an indentation, but always forgets the colon of the “for” “if” or “while” loop.
Note that the reason I mention Linux is because the Pycharm on Windows or Mac has no such issue, because I just switch from Windows to Linux. I did try different versions of Pycharm on Linux, but unfortunately this issue is same cross the line.

Comment actions Permalink

Ok, so I understand you're talking about "Complete current statement" shortkey? Ctrl+Shift+Enter by default

I've tested this but haven't seen any difference in behavior on Linux vs Windows - the statement is completed correctly with the colon at the end.

Check what hotkey is mapped to that action in your keymap settings.

Comment actions Permalink

Great!!! Thank you so much for asking me to double check.

What happen is that I use a customized keyboard, I probably accidentally change the "Meta" key, so it behavior as just jump the next line. I add another new keybinding for the  "Complete Current Statement", now it works like a magic!


Please sign in to leave a comment.