Customizing code auto-completion

Code completion is discussed in this manual's section on writing source code. In KDevelop, it comes from two sources: the editor, and the parse engine. The editor (Kate) is a component of the larger KDE environment and offers auto-completion based on words it has already seen in other parts of the same document. Such auto-completions can be identified in the tooltip by the icon that precedes it:



The editor's code completion can be customized via SettingsConfigure EditorEditingAuto Completion. In particular, you can select how many characters you need to type in a word before auto-completion kicks in.

On the other hand, KDevelop's own auto-completion is much more powerful as it takes into account semantic information about the context. For example, it knows which member functions to offer when you type object., etc., as shown here:



This context information comes from various language support plugins, which can be used after a given file has been saved (so it can check the filetype and use the correct language support).

KDevelop's completion is set to appear as you type, right away, pretty much everywhere that it could possibly complete something. This is configurable in SettingsConfigure KDevelopLanguage Support. If it isn't already set (as it should, by default), make sure Enable Automatic Invocation is set.

KDevelop has two ways to show a completion: Minimal Automatic Completion shows just the basic information in completion tooltips (i.e. the namespace, class, function, or variable name). This will look similar to Kate completion (except for the icons).

On the other hand, Full completion will additionally show the type for each entry, and in the case of functions, also the arguments they take. Also, if you are currently filling in the arguments to a function, full completion will have an additional info-box above the cursor that will show you the current argument you are working on.

KDevelop's code completion should also bring-to-top and highlight in green any completion items that match the currently expected type in both minimal and full completion, known as best-matches.

The three possible choices for the completion level in the configuration dialog are:

  • Always minimal completion: Never show Full Completion

  • Minimal automatic completion: Only show Full Completion when auto-completion has been triggered manually (i.e., whenever you hit Ctrl+Space)

  • Always full completion: Always show Full Completion