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.
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.
Before and After: Comment-Driven Completions
def process_data(df):
# Gemini might generate: return df.dropna()
# ... or: return df.fillna(0)
# Neither is necessarily right
# 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
When to Accept vs. Verify
| Situation | Recommended action |
|---|---|
| Standard boilerplate you recognize immediately | Accept and move on |
| Library call with specific method names | Verify the method exists and the args are correct |
| Logic with conditions or loops | Read 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 yet | Reject; the model is hallucinating context |
Keyboard Shortcuts to Know
| Action | VS Code | JetBrains |
|---|---|---|
| Accept full completion | Tab | Tab |
| Accept word by word | Ctrl+Right | Ctrl+Right |
| Next suggestion | Alt+] | Alt+] |
| Previous suggestion | Alt+[ | Alt+[ |
| Dismiss suggestion | Escape | Escape |
| Trigger manually | Ctrl+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.
Ready to Go Deeper?
Live instructor-led courses from our partners. Affiliate disclosure.