Beginner

Code Completion That Actually Helps

Inline completions are the highest-frequency interaction with Gemini Code Assist. Understanding how they work and what shapes their quality turns a useful tool into a reliable one.

✍️ AI School Editorial Team · Lilly Tech Systems 📅 Published Aug 27, 2026 · Reviewed Aug 27, 2026

How Ghost Text Works

When you pause typing (or after the configured delay), Gemini Code Assist sends a snapshot of your current file to Google's servers. The model predicts what code should follow the cursor and returns it as a "ghost text" suggestion rendered in grey inside the editor. Pressing Tab accepts the suggestion; pressing Escape or continuing to type dismisses it.

The model returns a single best completion by default, not a ranked list. You can cycle through alternatives using Alt+] (next) and Alt+[ (previous) in VS Code, or the equivalent JetBrains shortcuts. In practice, the first suggestion is correct most of the time for boilerplate; for logic-heavy completions, cycling through alternatives often reveals a better option.

What Context the Model Reads

Completion quality depends heavily on what context is included in the request. Gemini Code Assist builds this context from:

  • The current file up to the cursor. The most important signal. Everything you have written above the insertion point is included verbatim.
  • The current file after the cursor. The "suffix" - the code that already exists below the cursor. This allows fill-in-the-middle completions that slot correctly between existing code.
  • Import statements and type signatures. The model reads your imports and uses them to generate completions that reference the right library names, types, and idioms. Correct imports improve suggestion quality significantly.
  • Recently opened files. Files you have had open in the same session are kept in a cross-file context window. If you switch between a service interface and its implementation, completions in the implementation can reference the interface correctly.
Write a comment first. For non-trivial functions, writing a comment that describes what the function does before the function signature dramatically improves completion quality. The model treats the comment as intent, and the completion implements the intent. This is the single highest-leverage habit for better completions.

Before and After: Comment-Driven Completions

Without a comment - vague function name, generic completion
def process_data(df):
    # Gemini might generate: return df.dropna()
    # ... or: return df.fillna(0)
    # Neither is necessarily right
With a comment - specific intent, better completion
# Remove rows where age is negative or over 120,
# then fill missing income values with the column median.
def clean_user_data(df):
    # Gemini generates the correct implementation:
    df = df[df['age'].between(0, 120)]
    df['income'] = df['income'].fillna(df['income'].median())
    return df

The comment tells the model exactly what "clean" means in this context. Generic function names like process_data leave too much ambiguity - the model's best guess may be technically valid but wrong for your use case.

Multi-Line Completions

Gemini Code Assist regularly generates completions that span multiple lines - entire function bodies, class initializers, or setup sequences. This is where the time savings are largest, because the model can produce twenty lines of correct boilerplate in a second that would take you two minutes to write.

Multi-line completions work best for:

  • Standard patterns - REST API handlers, database model definitions, test fixtures, configuration parsers
  • Language translations - converting logic you have in one language to another
  • Completing a partially written block - if you have already written the first few lines of a pattern, the model can see the pattern and complete it
⚠️
Always read multi-line completions before accepting. The model can generate plausible-looking code with subtle logic errors - an off-by-one in a loop, a missing null check, an incorrect API method name. The longer the completion, the more likely it contains at least one error. Treat multi-line completions as drafts, not finished code.

When to Accept vs. Verify

SituationRecommended action
Standard boilerplate you recognize immediatelyAccept and move on
Library call with specific method namesVerify the method exists and the args are correct
Logic with conditions or loopsRead the whole completion carefully before accepting
Security-sensitive code (auth, crypto, SQL)Never accept without manual review; prefer writing by hand
Completion references a variable that doesn't exist yetReject; the model is hallucinating context

Keyboard Shortcuts to Know

ActionVS CodeJetBrains
Accept full completionTabTab
Accept word by wordCtrl+RightCtrl+Right
Next suggestionAlt+]Alt+]
Previous suggestionAlt+[Alt+[
Dismiss suggestionEscapeEscape
Trigger manuallyCtrl+Space (then arrow to Gemini)Alt+\

Languages and File Types

Gemini Code Assist supports completions in over 20 programming languages. Quality varies by language - languages with large training data (Python, JavaScript, TypeScript, Java, Go, C++) produce more accurate completions than niche languages. For configuration files (JSON, YAML, TOML), completions are useful for known schemas (Kubernetes manifests, GitHub Actions) but may generate incorrect values for proprietary formats the model has not seen.

📚
See also: Completion quality depends partly on how well you phrase your comments and function names - that is prompt engineering applied to code. The Prompt Patterns That Survive Production course covers the principles of clear intent specification that apply in both chat and completion contexts.

Ready to Go Deeper?

Live instructor-led courses from our partners. Affiliate disclosure.