clang array completion
Autocompletes array variables in C/C++ with their subscripts already written out. Type the array
name, accept the suggestion, and you get matrix[0][0] with the cursor on the first index instead
of a bare identifier you still have to bracket by hand.
Features
- Workspace-wide array detection — array declarations are collected from every C/C++ file in
the open workspace folders, not just the file you are editing, so an array declared in another
translation unit or a header still completes.
- Dimension-aware snippets — the number of
[] pairs matches how the array was declared, so a
1D array completes as name[0], a 3D array as name[0][0][0].
- Tab through the indices — each subscript is a snippet placeholder pre-filled with
0; press
Tab to jump to the next one and type the real index.
- Array suggestions ranked first — completions from this extension sort above the rest of the
suggestion list, so the bracketed form is the default choice rather than one you scroll to.
- Cache kept fresh in the background — the workspace is scanned once at startup, re-scanned when
you save a C/C++ file, and dropped when files are deleted or renamed, so completion itself never
waits on a disk scan.
Usage
Works automatically in files VS Code treats as c or cpp. Start typing an array name and the
bracketed completion appears in the normal suggestion list; accept it and Tab between indices.
Array sizes may be numeric literals or named constants — int data[MAX_SIZE]; is detected the same
as int data[10];.
Limitations
Declarations are found by pattern matching over the file text, not by parsing, so unusual
declaration forms may be missed and scope is not tracked (a local array in one file will still be
suggested in another). The scan covers at most 100 files, skips files larger than 500 KB, descends
at most 5 directory levels, and ignores node_modules, .git, build, dist, out, bin and
obj. When the same array name appears with different dimensions, the largest one wins.
Requirements
Visual Studio Code 1.104.0 or later. No configuration and no commands are contributed.