How to Auto-Fill the First Greyed-Out Suggestion in Visual Studio 2022
Visual Studio 2022 introduced powerful AI-driven features like IntelliCode whole-line completions and GitHub Copilot integration. These tools display greyed-out "ghost text" inline suggestions right in your editor. However, many developers run into frustration when pressing Tab accepts an IntelliSense dropdown item instead of the greyed-out inline suggestion.
Understanding the Difference: IntelliSense vs. Inline Predictions
Before customizing shortcuts, it is helpful to understand why this behavior happens:
- IntelliSense Pop-up Menu: The traditional dropdown list offering method, variable, and class completions.
- Inline Predictions (IntelliCode / Copilot): The greyed-out ghost text that predicts whole lines or blocks of code ahead of your cursor.
When both are active, keypresses like Tab can sometimes conflict depending on which feature currently has focus.
How to Accept the Greyed-Out Inline Suggestion
By default, Visual Studio 2022 assigns the following controls to inline ghost text:
- Accept entire suggestion: Press
Tab(when the IntelliSense popup is closed or when inline prediction is focused). - Accept word-by-word: Press
Ctrl + Right Arrowto insert the ghost text one word at a time. - Accept next character: Press
Right Arrow.
If pressing Tab selects a item from the IntelliSense popup instead of inserting the greyed-out text, you can dismiss the pop-up menu first by hitting Esc, then press Tab to auto-fill the inline suggestion.
How to Customize the Keyboard Shortcut
If you want a dedicated key combination specifically to accept the greyed-out prediction regardless of IntelliSense context, you can remap the command in Visual Studio:
- Navigate to Tools > Options in the top menu bar.
- Expand Environment and select Keyboard.
- In the Show commands containing search box, type
Edit.AcceptInlinePrediction. - Select
Edit.AcceptInlinePredictionfrom the list. - Click in the Press shortcut keys box and input your preferred shortcut (e.g.,
Alt + Right ArroworTab). - Click Assign, then press OK to save your changes.
Tweak IntelliCode Settings for Better Results
If inline predictions are not appearing reliably or are interfering with your typing flow, adjust your IntelliCode options:
- Go to Tools > Options > IntelliCode > General.
- Ensure Show completions for lines of code is checked.
- If you prefer inline completions over the standard popup, you can toggle Apply completions on Tab settings to fit your workflow.
By mastering these shortcuts and setting custom bindings for Edit.AcceptInlinePrediction, you can drastically speed up refactoring tasks and code editing in Visual Studio 2022.