You have already met code completion in the Getting Started Guide. Let's explore this feature in more detail.
Code completion shows a list of words (a suggestion list), which are relevant to the current location in the given visibility scope.
In this brief tutorial, we'll learn about:
To show code completion at any time, press Ctrl+Space.
Actually, by default the suggestion list pops up automatically. whenever you start typing. It is also triggered by typing a dot after a symbol name. As you go on typing, the suggestion list shrinks and shows the matching entries only. Note also, that the suggestion list is smart enough, and recognizes the names when only their parts, regardless of their position, are entered:
If you are crossed with the list popping up when you do not want to see it, you can disable this feature by clearing the check box Autopopup code completion in (ms) (Ctrl+Alt+S → Settings → Editor → Code Completion). In this case you have to invoke code completion explicitly.
Use your mouse pointer or the up and down arrow keys to choose the desired variant.
(By the way, you can use the right and left arrow keys to make the suggestion list narrower or wider.)
When ready, you have to insert the selected symbol. PyCharm suggests two ways to do it.
- First, press Enter - the selected variant is added at the insertion point:
- Second, press Tab - in this case, the selected variant replaces the string to the right of the insertion point:
Press Ctrl+Alt+S to open the Settings dialog, expand the Editor node, and click Code Completion page:
As you can see, PyCharm allows to change all the behaviors of code completion to fit your requirements. Press the "Help" button if you're not sure about some particular option.
To learn more about code completion, follow this link.