Skip to content

Code Completion ​

Candidates for what is being typed: names, members, calls, headers and modules.

Symbols ​

Names in scope complete as you type, and a qualifier such as ns:: lists what that scope declares.

Supported

Fuzzy unqualified lookup

Strong prefix matches survive, while weak subsequence matches do not

Supported

Class template deduplication

A class template with constructors and a deduction guide stays a single entry

Supported

Macros

Object-like macros complete as constants, function-like ones as functions with a parameter signature

Their arguments follow the functions' setting, code_completion.arguments.

Supported

Namespace-qualified lookup

ns:: lists the namespace's own members

Supported

Enum members

A scoped enum lists its enumerators through Type::, an unscoped enumerator completes by its bare name

Supported

Required qualifier

An enumerator the bare name does not reach completes with the qualifier it needs, matched against its bare name

Supported

Documentation

An item shows the documentation comment of what it names, a member of a template's instantiation the one its template wrote

Other Namespaces ​

A name another namespace declares completes too, with the qualifier that reaches it; one the file does not include or import yet brings the #include or the import it needs.

Supported

Names of other namespaces

A name another namespace declares completes with the qualifier that reaches it, after the names in scope

Supported

Headers not included yet

A name the project declares in a header the file does not include yet completes with the #include that brings it

Supported

Modules not imported yet

A name a module of the project exports completes with the import that brings it, its own partitions by their partition name

Supported

Written scopes

A name a header the file does not include yet declares completes after the namespace written before it (std::vec)

It comes with the #include that brings it, whether the file already knows the namespace or not. After a namespace alias, a macro or a class, only what the file reaches is offered.

Member Access ​

After ., -> or ::, the members of the object or the scope complete.

Supported

Members after a dot

Completing after a dot lists the members of the object's class

Supported

Scope-qualified members

After Class:: static data, nested types, methods and the injected class name all list

Qualified completion is not filtered to what a static context can use: instance fields and the destructor show up alongside the static members and nested types.

Supported

Inherited members

A derived object completes its own members and those of its base

Supported

Designated initializer fields

{ . lists the fields of the aggregate being initialized, those of a matching partial specialization for a dependent one

Supported

Inaccessible members

Private and protected members are not offered where they cannot be used

Supported

Out-of-line definitions

After Class:: in a definition, every member is offered, private ones included

Supported

Dot on a pointer

After . on a pointer, the members -> reaches complete and turn the . into ->

Functions and Snippets ​

A function completes as a call, with what code_completion.arguments asks for between its parentheses. All options below live in the [code_completion] configuration section.

Supported

Parameter placeholder snippets

Calls insert tab-stop placeholders per argument; a no-argument function gets its empty parentheses

With delimiters, a call gets its parentheses with the cursor between them; with none, the name alone.

Supported

Signature and return type

The parameter list and the return type ride along with a function's name

Supported

Overload bundling

An overload set collapses into one entry with an overload count

With bundling off, every overload is its own entry with its own signature.

Supported

Call parentheses

A completed call gets its parentheses, unless arguments already follow the name or it is not being called; a < after a function that is no template compares, and opens no arguments

Supported

Template argument placeholders

A class template inserts a placeholder per template parameter without a default, and empty brackets when every parameter has one

Supported

Statement keywords

Statement keywords complete as keywords; the option inserts the whole statement with a placeholder for each part

Supported

Objective-C methods

A message completes its selector with a placeholder for each argument, from the piece the cursor is at; in a message to super the method being written passes its own arguments on. A method declared in an implementation gets its whole declaration, and after a dot a method taking no argument reads as a property

The list shows a selector's first piece, the rest as its signature. With delimiters the arguments are empty tab stops; with none, and where an argument is written already, the piece alone.

Templates and Concepts ​

Inside a template, members complete even where they depend on its parameters.

Supported

Dependent member type

A variable whose type is a member alias of a dependent specialization completes the members of the class the alias stands for

The alias is resolved with the written template arguments substituted, so Vec<Vec<T>>::value_type lists the members of Vec<T> rather than nothing at all. An alias naming a reference (Vec<Vec<T>>::reference) lists the members of the class referred to, and -> on a pointer to one lists the pointee's.

Supportedclangd#443

Dependent expression results

A member access on what a subscript or a member call returns inside a template completes the members of the class it evaluates to

rows[0]. on a Vec<Vec<T>> lists the members of Vec<T>, followed through the container's reference alias the way the standard containers declare it. Where a member has a const overload, the constness of the object picks the one called, a data member reached through a const object counting as const, and -> on a returned iterator reaches the element.

Supported

Deduced variable members

A variable declared auto from a dependent initializer completes the members of the class it deduces to

auto& row = rows[0]; row. lists the members of Vec<T>. The declarator applies as in a real deduction: const auto& makes the object const, a by-value auto drops the initializer's const, auto&& and decltype(auto) keep it, and auto* takes the pointee. From a data member, decltype(auto) takes the type the member is declared with, or with parentheses the const reference the expression is.

Generic lambda parameters

An auto parameter of a lambda completes the members of the type the lambda is called with

The call can come after the lambda, or be the algorithm the lambda is passed to. A lambda called with several types completes the names every one of them has.

Supportedclangd#1103

Concept requirements

Inside a constrained template, the members the concept requires complete after a dot

A member the concept calls completes as a method with the types of the arguments it is called with; after T:: the nested types it names complete too.

Supported

Members through a dependent specialization

The members of a dependent specialization of a class template show the arguments the code names it with

After m.find(1)-> over a lib::map<int, T>, first is a const int and second a T, not the pair's own _T1 and _T2.

Supported

Several instantiations

A template the code calls with several types completes the names every one of them has

Each name is listed with the overloads each type declares for it. Inside a branch of an if constexpr, only the types that take the branch count. A call written before the template counts as well as one after it; past eight types, the first eight decide. When one of the types is not a class, no name is shared and nothing is offered.

Override and Out-of-line Definitions ​

Inside a derived class, the virtual functions of its bases complete as whole declarations.

Supported

Override declarations

Inside a derived class, a base class's virtual function completes as a whole override declaration, return type and override included

Inside the override, the name completes as a call, not as another declaration.

Preprocessor Directives ​

After the # that opens a line, the preprocessor directives complete, and after #ifdef the macros defined above it.

Supported

Directive names

After a #, the directives complete, and #elif, #else and #endif only inside a conditional block; with statement_snippets, each form with placeholders for its arguments

Include Paths ​

After #include, header names complete. A typed name matches a whole name first, then a prefix, then words of a name (view finds string_view); names that match alike list a quoted one's from the includer's own directory first, then from the include directories, the system's last. Files that look like headers come before the others: header extensions everywhere, extensionless files in system directories and other places such headers live; a source or text file, and a builtin header of clang's that must not be included directly (<avxintrin.h>), follow. A framework directory offers its frameworks, and past one their headers.

Supported

Quoted include paths

Completion lists headers and directories from the configured search path and marks directories with a trailing slash

Supported

Angled include paths

Angled includes offer the same search-path candidates, closed with >

Supported

Closing delimiter

Accepting a header closes the directive, replacing what was already typed after the cursor instead of doubling it

A delimiter already there is replaced, and so is the rest of a path when the header is picked in an earlier path component. A name with spaces is replaced through its closing delimiter; without one, it ends at its first space.

Supported

Headers beside the file

A quoted include finds the headers next to the including file without any search path

Supported

Nearest headers first

Header names that match alike list the includer's directory first, then the quoted include directories, the others in order, the system's last; a name two directories hold is listed once, from the first

Supported

Library internals last

A library's reserved names (__algorithm/, _mingw.h) come after the other names of their search group, hidden ones (.git/) after all the others

Supported

Framework headers

In a framework directory (-F, -iframework, the SDK's on macOS) the frameworks complete as directories, and past one their headers: <Foo/Bar.h> is Foo.framework/Headers/Bar.h

Supported

Words of names

A typed name matches a whole name first, then a prefix, then the words of a name, ahead of the order of the directories: wsnap_view lists the system's wsnap_view, then wsnap_viewport.h, then old_wsnap_view.h

Module Import ​

After import or export import, module names complete. A typed name matches a whole name first, then a prefix, then words of a name (compat finds app.compat); names that match alike list the unit's own partitions first, then the modules whose interface lies nearest the file.

Supported

Import statements

Known module names complete after import, with the closing semicolon inserted

Supported

Partitions of the current module

In an implementation unit, the module's own partitions complete as :partition, while neither the module itself nor the partitions of other modules are offered

A statement that already ends in a semicolon keeps it.

Supported

Partitions in interface units

In an interface unit, only the module's interface partitions complete

An interface cannot export an internal partition, and names it imports from one may not reach the interface's importers, so internal partitions are offered only to the module's other units.

Supported

Nearest modules first

Module names list the modules whose interface lies nearest the file first

Supported

Module documentation

A module offered after import shows the comment above its interface unit's module declaration

Supported

Words of module names

A typed name matches a whole module name first, then a prefix, then the words of a name, ahead of where the interface lies: compat lists the distant compat, then the nearby compat_legacy and app.compat

Filtering ​

What you typed filters the candidates by the starts of their words.

Supported

Underscore filtering

Underscore-prefixed internal symbols hide unless the typed prefix itself starts with one

Supported

Deprecated tagging

A [[deprecated]] candidate is marked deprecated and ranks after its plain sibling

Supported

Word-boundary fuzzy match

Prefix fb matches the word starts of foo_bar_baz

frobnicate is only a weak scattered subsequence of fb and is dropped; foo_bar_baz matches on the foo and bar word boundaries and survives.

Supported

Prefix outranks subsequence

An exact-prefix candidate sorts above a scattered subsequence match

For prefix fo, format_output is a true prefix and outscores fast_math_operation, which only matches as a subsequence.

Supported

Completion inside a word

Completing in the middle of a word offers both ranges: the editor either inserts before the rest of the word or replaces the whole word

Ranking ​

Among the candidates left, the names closest to the code come first, and those of the type the code expects.

Supported

Closest names first

Among the names a prefix matches, locals come first, then the class's members, then the file's names, macros last

Supported

Expected type first

A name of the type the code expects ranks above the others its prefix matches

Trigger Characters ​

Registered: . < > : " / # and space.

CharacterContextBehavior
.Member accessSemantic completion
>Via ->Pointer member completion; any other > is ignored
:Via ::Scope completion
<#include <Include path completion
"#include "Include path completion
/Path separatorInclude path continuation
After importModule name completion (extension-gated)
#Line startDirective name completion; any other # is ignored