How does Cursor's AI code completion work?
How it generates suggestions
Cursor's AI completion, often called 'Copilot++' or just 'AI autocomplete', runs in the background as you edit. It looks at the code before and after your cursor, the file's language, and sometimes other files in your project to predict what you likely want to write next. The suggestions appear as grayed-out text.
You can accept a suggestion by pressing Tab, or ignore it by typing something else. The AI learns from your acceptances and rejections to improve over time, though it doesn't train on your code unless you explicitly allow it.
Context and customization
Cursor uses a combination of local analysis and cloud-based AI models. For better suggestions, you can enable codebase indexing in Settings, which lets the AI reference your entire project. This is especially useful for large codebases with custom functions and patterns.
You can toggle AI completion on or off, and adjust settings like suggestion delay or whether to use multi-line completions. The exact options depend on your Cursor version, but they're typically found under Settings > AI.
- Accept with Tab, reject by typing.
- Enable indexing for project-wide context.
- Adjust settings for delay and multi-line.
- Works with many programming languages.
Common mistakes
- Expecting perfect completions for every line; it's a tool, not a replacement for thinking.
- Not enabling codebase indexing, which limits context to the current file.
- Confusing AI completion with chat or Composer; they are separate features.
