Chat

Overview

Cursor Chat allows you to use the most powerful language models directly in your editor to ask questions or solve problems in your codebase.

https://mintlify.s3.us-west-1.amazonaws.com/cursor/images/chat/chat.png

For language models to provide good answers, they need to understand specific content related to your codebase — that is, context.

Cursor has several built-in features for providing context in chat, such as automatically including the entire codebase context, searching the web, indexing documentation, and user-specified code block references. These features are designed to eliminate the tedious copy-paste work required when using language models to work with code.

By default, Cursor Chat is located in the AI panel, which is opposite to the main sidebar. You can toggle the AI panel by pressing Ctrl/⌘ + L, which will focus on the chat box when opened. To submit a query, press Enter.

User and AI Messages

User messages contain your input text and the context you reference. You can return to any previous user message to edit and rerun queries. This will override any subsequent messages and generate new ones.

AI messages are responses generated by your chosen AI model. They are paired with the preceding user messages. AI messages may contain parsed code blocks that can be added to your codebase through instant application.

All user/AI messages in the same thread are collectively called a chat thread, and each chat thread is saved in your chat history.

Chat History

You can view chat history by clicking the "Previous Chats" button in the top right of the AI panel, or by pressing Ctrl/⌘ + Alt/Option + L. You can click any chat thread to return to view the messages that make up that thread, and you can modify thread titles by clicking the pencil icon or delete threads by clicking the trash can icon when hovering over a thread in the history.

Cursor thread titles are just the first few words of the first user message.

Default Context

By default, Cursor Chat includes the current file as context. You can submit a query without any context by deleting the current file tag from the message. You can see what will be included in the context in the tags above the input box while typing.

Adding Context

By default, user messages will include your input text and the context you reference. You can use the @ symbol to add more custom context to each bubble, and by default, the currently viewed file is also used as context in user messages.

For more information, see the @ Symbols page.

AI Fixes in Chat

Using AI fixes in chat is a convenient feature for fixing linter errors in your codebase. To use this feature, hover over an error in the editor and click the blue AI fix button that appears.

The keyboard shortcut for this feature is Ctrl/⌘ + Shift + E.

https://mintlify.s3.us-west-1.amazonaws.com/cursor/images/chat/ai-fix.png

Customization

Selecting AI Models

Choose your preferred AI model through the model switcher, and Cursor Chat will use that model to generate responses. You can switch between models by pressing Ctrl/⌘ /.

By default, Cursor Chat uses OpenAI's GPT-4 as its AI model (specifically, the gpt-4 label points to our GPT4-Turbo instance).

The AI model you choose for chat will be saved for future sessions, so you don't have to change it every time you open Cursor Chat.

https://mintlify.s3.us-west-1.amazonaws.com/cursor/images/chat/model-toggle.png

Using in Editor

Cursor Chat can also be used as an editor tab by clicking the horizontal "More" button and then clicking the "Open Chat in Editor" button. Cursor Chat will then behave as a regular editor tab. Pressing Ctrl/⌘ + L will open the chat tab and focus on it.

Settings

You can customize Cursor Chat under Cursor Settings > Features > Chat.

These settings include:

  • Always search the web for answers.
    • This will make the AI model browse the web for the latest information with every query.
  • Add chat fade-in animation.
    • This adds smooth animation when generating AI messages.
  • Auto-scroll chat.
    • This will automatically scroll the chat when AI is generating text when at the bottom of a thread.
  • Narrow scrollbar in chat panel.
  • Show chat history when starting new chat.

Working with Codebase

Default Codebase Chat

If your codebase is not indexed, Cursor Chat will first try to compute several search queries to search in your codebase. For better accuracy, it's recommended to use embeddings search.

https://mintlify.s3.us-west-1.amazonaws.com/cursor/images/chat/no-embeddings.png

Embeddings Search

With codebase indexing, Cursor Chat can generate responses accurately based on your codebase.

By pressing Ctrl/⌘ + Enter after entering your message, Cursor Chat will scan your indexed codebase to find relevant code snippets. This is typically good for quickly including code snippets you want to incorporate into the conversation context. For better control over codebase search and higher accuracy, you can use @codebase.

https://mintlify.s3.us-west-1.amazonaws.com/cursor/images/chat/embeddings.png

Advanced Codebase Search

When using @Codebase, Cursor codebase chat performs a more detailed search.

See more about @Codebase here.

Apply

Cursor's Apply feature allows you to quickly integrate code block suggestions from chat into your code.

Applying Code Blocks

To apply a code block suggestion, you can click the play button in the top right of each chat code block.

https://mintlify.s3.us-west-1.amazonaws.com/cursor/images/chat/apply.png

This will edit your file to incorporate the chat-generated code. Since you can add the most context and have the most back-and-forth with the model in chat, we recommend using chat + apply for more complex AI-driven code changes.

Accept or Reject

After applying a code block, you can review the diff and accept or reject the changes. You can also click the "Accept" or "Reject" buttons in the top right of the chat code block.

Ctrl/⌘ Enter to accept, Ctrl/⌘ Backspace to reject.

https://mintlify.s3.us-west-1.amazonaws.com/cursor/images/chat/accept-apply.png