Basic Usage 基本用法
In Cursor’s AI input boxes, such as in Cmd K, Chat, or Terminal Cmd K, you can use @ symbols by typing @. A popup menu will appear with a list of suggestions, and it will automatically filter to only show the most relevant suggestions based on your input.
在 Cursor 的 AI 输入框中,例如 Cmd K、Chat 或终端 Cmd K,您可以通过键入 @ 来使用 @ 符号。将出现一个带有建议列表的弹出菜单,它将自动过滤以仅显示基于您输入的最相关建议。
Keyboard Shortcuts 键盘快捷键
You can navigate through the list of suggestions using the up/down arrow keys. You can hit Enter to select a suggestion. If the suggestion is a category, such as Files, the suggestions will be filtered to only show the most relevant items within that category.
您可以使用向上/向下箭头键浏览建议列表。您可以按 Enter 键选择建议。如果建议是一个类别,例如 Files (文件),则建议将被筛选为仅显示该类别中最相关的项目。
Cmd K Keyboard Shortcut Cmd K 键盘快捷键
You can use the up/down arrow key to navigate through the list of selected Cmd K @ symbols, Enter to expand/collapse the selected context item. For file references, you can use Ctrl/⌘ M to toggle the file reading strategies. Read more about file reading strategies here.
您可以使用向上/向下箭头键在选定的 Cmd K @ 符号列表中导航,使用 Enter 键展开/折叠选定的上下文项。对于文件引用,您可以使用 Ctrl/⌘ M 切换文件读取策略。在此处阅读有关文件读取策略的更多信息。
@Files
In AI input boxes such as in Cursor Chat and Cmd K, you can reference entire files by using @Files. Also, if you continue to type after @, you will see your file search results after the @Code strategy.
在 AI 输入框中(如 Cursor Chat 和 Cmd K),可以使用 @Files 引用整个文件。此外,如果您继续在 @ 后键入,您将在 @Code 策略之后看到您的文件搜索结果。
In order to make sure the file you’re referencing is the correct file, Cursor will show a preview of the file’s path. This is especially useful when you have multiple files with the same name in different folders.
为了确保您引用的文件是正确的文件,Cursor 将显示文件路径的预览。当您在不同的文件夹中有多个同名文件时,这尤其有用。
聊天长文件引用
In Cursor’s Chat, if the contents of a file is too long, Cursor will chunk the file into smaller chunks and rerank them based on relevance to the query.
在 Cursor 的聊天中,如果文件的内容太长,Cursor 会将文件分块为较小的块,并根据与查询的相关性对它们进行重新排序。
Cmd K 分块策略
For Cmd K, Cursor uses the file references differently based on the content length as well.
对于 Cmd K,Cursor 也会根据内容长度以不同的方式使用文件引用。
-
auto 自动
- Automatically pick one of the three reading strategies based on the file size
根据文件大小自动选择三种读取策略之一
- Automatically pick one of the three reading strategies based on the file size
-
full file 完整文件
- The entire file is used as context.
整个文件将用作上下文。
- The entire file is used as context.
-
outline 大纲
- Cursor parses the outline of the file and uses the information as context.
Cursor 解析文件的轮廓,并将该信息用作上下文。
- Cursor parses the outline of the file and uses the information as context.
-
chunks 块
- Cursor chunks the file into smaller chunks and picks the most relevant one.
Cursor 将文件分块为较小的块,并选择最相关的块。
- Cursor chunks the file into smaller chunks and picks the most relevant one.
Drag and Drop 拖放
You can drag and drop files from the primary sidebar into Chat or Cmd K to add them as context as well.
您可以将文件从主侧边栏拖放到 Chat 或 Cmd K 中,以将它们也添加为上下文。
@Folders
Currently, @Folders is only supported in the Cursor Chat.
目前,@Folders仅在 Cursor Chat 中受支持。
You can also reference entire folders in Cursor as context. @Folders is especially useful for long context chat where you want to provide a lot of context to the AI.
您还可以将 Cursor 中的整个文件夹作为上下文引用。@Folders 对于您希望为 AI 提供大量上下文的长上下文聊天特别有用。
@Code
To reference specific sections of code, you can use the @Code symbol.
要引用代码的特定部分,您可以使用 @Code 符号。
Code Preview 代码预览
Similar to the @Files symbol, Cursor will show a preview of the code’s content so you can verify that the code you’re referencing is the correct one.
与 @Files 符号类似,Cursor 将显示代码内容的预览,以便您可以验证您引用的代码是否正确。
From the Editor 编者的话
Another way to add code snippets as context is to select the code you want to reference, and click on either “Add to Chat” (Ctrl/⌘ Shift L) or “Add to Edit” (Ctrl/⌘ Shift K).
将代码片段添加为上下文的另一种方法是选择要引用的代码,然后单击“添加到聊天”(Ctrl/⌘ Shift L)或“添加到编辑”(Ctrl/⌘ Shift K)。
These will add the selected code snippet to either the Chat input box or the currently active Cmd K prompt bar.
这些操作会将所选代码片段添加到 Chat 输入框或当前活动的 Cmd K 提示栏。
To add a selected code to a new chat, you can press Ctrl/⌘ L.
要将所选代码添加到新聊天中,您可以按 Ctrl/⌘ L。
@Docs
Cursor comes with a set of third party docs crawled, indexed, and ready to be used as context. You can access them by using the @Docs symbol.
Cursor 附带一组第三方文档,这些文档已爬取、索引并准备好用作上下文。您可以使用 @Docs 符号访问它们。
Add Custom Docs 添加自定义文档
If you want to crawl and index custom docs that are not already provided, you can do so by @Docs > Add new doc. The following modal will appear after you’ve pasted in the URL of your desired doc:
如果要对尚未提供的自定义文档进行爬网和索引,可以通过 @Docs > Add new doc 来实现。粘贴所需文档的 URL 后,将显示以下模式:
Cursor will then index and learn the doc, and you will be able to use it as context like any other doc.
然后 Cursor 将索引并学习文档,您将能够像任何其他文档一样将其用作上下文。
Manage Custom Docs 管理自定义文档
Under Cursor Settings > Features > Docs, you will see the docs you have added. You can edit, delete, or add new docs here.
在 Cursor Settings > Features > Docs 下,您将看到已添加的文档。您可以在此处编辑、删除或添加新文档。
@Git
Currently, @Git is only supported in the Cursor Chat.
目前,@Git仅在Cursor Chat中受支持。
In Cursor’s Chat, you can use @Git to add git commits, diffs, or pull requests to your prompt.
在 Cursor 的聊天中,您可以使用 @Git 将 git 提交、差异或拉取请求添加到您的提示中。
Common Use Cases 常见用例
One common use case for @Git is to allow Cursor’s AI to scan the diff and look for bugs or issues that could be caused by the diff.
@Git的一个常见用例是允许 Cursor 的 AI 扫描差异并查找可能由差异引起的错误或问题。
You could also use @Diff of Working State to generate a commit message from your current diffs.
您还可以使用 Working State 的 @Diff 从当前 diff 生成提交消息。
@Codebase
Through @Codebase, Cursor Chat goes through these steps until it finds the most important pieces of code to use.
通过 @Codebase,Cursor Chat 会完成这些步骤,直到找到要使用的最重要的代码段。
-
Gathering: scanning through your codebase for important files / code chunks
收集:扫描您的代码库以查找重要文件/代码块 -
Reranking: reordering the context items based on relevancy to the query
Reranking:根据与查询的相关性对上下文项重新排序 -
Reasoning: thinking through a plan of using the context
推理:思考使用上下文的计划 -
Generating: coming up with a response
生成:提出响应
Another way of submitting an advanced codebase query is to click on the dropdown next to the Ctrl/⌘ + Enter button and select reranker for the search behavior. This is only available when @Codebase isn’t used, otherwise @Codebase takes precedence.
提交高级代码库查询的另一种方法是单击 Ctrl/⌘ + Enter 按钮旁边的下拉列表,然后选择 reranker 作为搜索行为。仅当不使用 @Codebase 时,此选项才可用,否则 @Codebase 优先。
@Web
With @Web, Cursor constructs a search query based on the query and the context you’ve provided, and searches the web to find relevant information as additional context. This is particulary useful for finding the most up-to-date information.
借助 @Web,Cursor 会根据查询和您提供的上下文构建搜索查询,并在 Web 上搜索以查找相关信息作为附加上下文。这对于查找最新信息特别有用。
Always On 始终开启
You can make Cursor search the web for chat on every query by turning on “Always search the web” under Cursor settings > Features > Chat. This is equivalent to using @web on every query.
您可以通过打开 Chat >功能光标设置下的“始终搜索 Web”,使光标在每个查询中搜索 Web 聊天。这相当于对每个查询都使用 @web。
@Chat
This feature is currently only for Cmd K.
此功能目前仅适用于 Cmd K。
You can add your current chat messages as context by using @Chat inside Cmd K. This is useful for when you have a conversation with the AI that you’d like to be applied to edit or generate code.
您可以在 Cmd K 中使用 @Chat 将当前聊天消息添加为上下文。当您与希望应用于编辑或生成代码的 AI 进行对话时,这非常有用。
@Definitions
This feature is currently only for Cmd K.
此功能目前仅适用于 Cmd K。
The @Definitions symbol adds all nearby definitions to Cmd K as context.
@Definitions 符号将附近的所有定义作为上下文添加到 Cmd K 中。
@Paste Links 粘贴链接
In order for Cursor to visit a link before responding, type @ and then paste in the link.
为了让 Cursor 在响应之前访问链接,请键入 @,然后粘贴到链接中。
Remove Links 删除链接
By default, we automatically parse links and turn them into @Links in Cursor Chat. If you prefer to have the link as plain text, click on the link and then click Unlink.
默认情况下,我们会自动解析链接并将其转换为 Cursor Chat 中的@Links。如果您希望将链接设置为纯文本,请单击该链接,然后单击 Unlink(取消链接)。