本篇是中英双语版Cursor介绍文档,类似说明书,所以没有太“说人话”,觉得枯燥的话其他篇目中也有相应的人话版讲解。

如何使用本篇?

本篇不用当做枯燥的说明书现在看完并理解,我建议的用法先看其他篇动起来!然后当用到某项功能的时候,想要看官方介绍,作为大家的功能速查手册。

建议:善用 Ctrl+F ,进行关键词搜索,针对性阅读。

Get start 从这开始

功能介绍

Tab 选定

Cursor includes a powerful autocomplete that predicts your next edit. Once enabled, it is always on and will suggest edits to your code across multiple lines, taking into account your recent changes.
Cursor 包含强大的自动完成功能,可预测您的下一次编辑。启用后,它始终处于打开状态,并将考虑您最近的更改,跨多行建议对代码进行编辑。

Code Generation 代码生成

Cursor sees your recent changes, so it can predict what you want to do next.
Cursor 可以看到您最近的更改,因此它可以预测您下一步要做什么。
file

Multi-Line Edits 多行编辑

Cursor can suggest multiple edits at once, saving you time.
光标可以一次建议多个编辑,从而节省您的时间。
file

Smart Rewrites 智能重写

Type carelessly, and Cursor will fix your mistakes.
不小心输入,Cursor 会修复您的错误。
file

Cursor Prediction 光标预测

Cursor predicts your next cursor position so you can seamlessly navigate your code.
Cursor 会预测您的下一个光标位置,以便您可以无缝导航代码。
file

Chat 聊天

Chat lets you talk with an AI that sees your codebase. The chat can always see your current file and cursor, so you can ask it things like: "Is there a bug here?". You can add particular blocks of code to the context with ⌘+Shift+L or "@." You can chat with your entire codebase with ⌘+Enter.
Chat 允许您与看到您的代码库的 AI 交谈。聊天室始终可以看到您当前的文件和光标,因此您可以向它询问诸如:“这里有 bug 吗?您可以使用 ⌘+Shift+L 或 “@” 将特定代码块添加到上下文中。您可以使用 ⌘+Enter 与整个代码库聊天。

Codebase Answers 代码库答案

Use @Codebase or ⌘ Enter to ask questions about your codebase. Cursor will search your codebase to find relevant code to your query.
使用 @Codebase 或 ⌘ Enter 询问有关您的代码库的问题。Cursor 将搜索您的代码库以查找与您的查询相关的代码。
file

Reference your Code 引用您的代码

Reference code with @ symbols to be used as context for the AI. Just type @ to see a list of all the files and code symbols in your folder.
带有 @ 符号的参考代码,用作 AI 的上下文。只需键入 @ 即可查看文件夹中所有文件和代码符号的列表。
file

Use Images 使用图像

Hit the image button under chat or drag an image into the input box to include visual context into chat.
点击聊天下方的图片按钮,或将图片拖到输入框中,将视觉上下文包含在聊天中。
file

Ask the Web 询问 Web

Get up-to-date information from the internet with @Web. Cursor will search the web for you and use the latest information to answer your question.
使用 @Web 从 Internet 获取最新信息。Cursor 将为您搜索 Web 并使用最新信息来回答您的问题。
file

Instant Apply 即时申请

Apply the code suggestions from chat back into your codebase by clicking the play button on top of any chat codeblock.
通过单击任何聊天代码块顶部的 play 按钮,将聊天中的代码建议应用回您的代码库。
file

Use Documentation 使用文档

Reference popular libraries using @LibraryName, or add your own using @Docs → Add new doc.
使用 @LibraryName 引用常用库,或使用 @Docs →添加新文档 添加您自己的库。
file

⌘ K ⌘ 千

⌘ K lets you edit and write code with the AI. To edit, try selecting some code, click "Edit," and describe how the code should be changed. To generate completely new code, just type ⌘ K without selecting anything.
⌘ K 允许您使用 AI 编辑和编写代码。要进行编辑,请尝试选择一些代码,单击“编辑”,并描述应如何更改代码。要生成全新的代码,只需键入 ⌘ K,无需选择任何内容。

Fast Edits 快速编辑

Edit and write code with the AI. Select some code, click ⌘ K, and describe how the code should be changed. Or, generate new code with ⌘ K without selecting anything.
使用 AI 编辑和编写代码。选择一些代码,单击 ⌘ K,并描述应如何更改代码。或者,使用 ⌘ K 生成新代码,而不选择任何内容。
file

Terminal ⌘ K 终端 ⌘ K

Use ⌘ K in the terminal to write terminal commands in plain english. Cursor will convert them into the terminal command you need.
在终端中使用 ⌘ K 以简单的英语编写终端命令。Cursor 会将它们转换为您需要的终端命令。
file

Quick Questions 快速提问

If you have any quick questions about certain parts of your code, you can select and click on "quick question" to get your answer right away.
如果您对代码的某些部分有任何快速问题,您可以选择并单击“快速问题”以立即获得答案。

Migrate from VS Code 从 VS Code 迁移

Cursor is a fork of VS Code. This allows us focus on making the best way to code with AI, while offering a familiar text editing experience.
Cursor 是 VS Code 的一个分支。这使我们能够专注于使用 AI 编写代码的最佳方式,同时提供熟悉的文本编辑体验。

Import Extensions, Themes, Settings, and Keybindings

导入扩展、主题、设置和键绑定
You can import your VS Code configuration into Cursor with one-click. Navigate to Cursor Settings > General > Account.
您可以一键将 VS Code 配置导入 Cursor。导航到 光标设置 > 常规 > 帐户。
file

Staying Up to Date 保持最新状态

We periodically rebase Cursor onto the latest version of VS Code.
我们会定期将 Cursor 变基到最新版本的 VS Code 上。

Why Not an Extension? 为什么不进行扩展?

As a standalone application, Cursor has more control over the UI of the editor, enabling greater AI integration. Some of our features, like Cursor Tab and CMD-K, are not possible as plugins to existing coding environments.
作为独立应用程序,Cursor 可以更好地控制编辑器的 UI,从而实现更好的 AI 集成。我们的一些功能,如 Cursor Tab 和 CMD-K,不能作为现有编码环境的插件。

Settings 设置

You can open Cursor specific settings pane by clicking on the gear button top-right, by pressing Ctrl/⌘ + Shift + J, or with Ctrl/⌘ + Shift + P and typing Cursor Settings.
您可以通过单击右上角的齿轮按钮、按 Ctrl/⌘ + Shift + J 或 Ctrl/⌘ + Shift + P 并键入光标设置来打开光标特定设置窗格。
You can open VS Code specific settings with Ctrl/⌘ + Shift + P, and then typing VS Code Settings.
您可以使用 Ctrl/⌘ + Shift + P,然后键入 VS Code 设置来打开 VS Code 特定设置。

Why is the Activity Bar in Cursor horizontal?

为什么 Cursor 中的活动栏是水平的?
file

The activity bar is horizontal by default to save room for chat. If you prefer the normal vertical activity bar you can go to the VS Code settings and set workbench.activityBar.orientation to vertical, and restart Cursor.
默认情况下,活动栏是水平的,以便为聊天留出空间。如果您更喜欢正常的垂直活动栏,可以转到 VS Code 设置并设置为 workbench.activityBar.orientation vertical,然后重新启动 Cursor。

Usage 用法

For more pricing info, please visit Cursor Pricing.
有关更多定价信息,请访问 Cursor 定价

TAB 选定

Overview 概述

Cursor Tab is our native autocomplete feature. It’s a more powerful Copilot that suggests entire diffs with especially good memory.
Cursor Tab 是我们的原生自动完成功能。它是一个更强大的 Copilot,可以建议具有特别好内存的整个差异。

Powered by a custom model, Cursor Tab can:
Cursor Tab 由自定义模型提供支持,可以:

  • Suggest edits around your cursor, not just insertions of additional code.
    围绕光标建议编辑,而不仅仅是插入其他代码。
  • Modify multiple lines at once.
    一次修改多行。
  • Make suggestions based on your recent changes and linter errors.
    根据您最近的更改和 linter 错误提出建议。

Free users receive 2000 suggestions at no cost. Pro and Business plans recieve unlimited suggestions.
免费用户可免费获得 2000 条建议。Pro 和 Business 计划会收到无限的建议。

UI 用户界面

When Cursor is only adding additional text, completions will appear as grey text. If a suggestion modifies existing code, it will appear as a diff popup to the right of your current line.
当 Cursor 仅添加其他文本时,补全将显示为灰色文本。如果建议修改了现有代码,它将在当前行的右侧显示为 diff 弹出窗口。

file
file

You can accept a suggestion by pressing Tab, or reject it by pressing Esc. To partially accept a suggestion word-by-word, press Ctrl/⌘ →. To reject a suggestion, just keep typing, or use Escape to cancel/hide the suggestion.
您可以通过按 Tab 键接受建议,也可以通过按 Esc 键拒绝建议。要逐字部分接受建议,请按 Ctrl/⌘ →。要拒绝建议,只需继续输入,或使用 Escape 取消/隐藏建议。
Every keystroke or cursor movement, Cursor will attempt to make a suggestion based on your recent changes. However, Cursor will not always show a suggestion; sometimes the model has predicted that there’s no change to be made.
每次击键或光标移动时,Cursor 都会尝试根据您最近的更改提出建议。但是,Cursor 不会始终显示建议;有时,模型预测不会做出任何更改。
Cursor can make changes from one line above to two lines below your current line.
Cursor 可以从当前行上方的一行更改为当前行下方的两行。

Toggling 切换

To turn the feature on or off, hover over “Cursor Tab” icon on the status bar in the bottom right of the application.
要打开或关闭该功能,请将鼠标悬停在应用程序右下角状态栏上的“光标选项卡”图标上。

Migrate from GitHub Copilot 从 GitHub Copilot 迁移

Tab Improvements 选项卡改进

The biggest difference is the way Cursor and GitHub Copilot complete code.
最大的区别是 Cursor 和 GitHub Copilot 完成代码的方式。
GitHub Copilot can insert text at your cursor position. It cannot edit the code around your cursor or remove text.

GitHub Copilot 可以在光标位置插入文本。它无法编辑光标周围的代码或删除文本。
Cursor can insert text at your cursor, and much more:
Cursor 可以在光标处插入文本,还有更多功能:

  • Multi-character edits 多字符编辑
    file

  • Instruction-based edits 基于指令的编辑
    file

Migrate from GitHub Copilot从 GitHub Copilot 迁移

Since Cursor comes by default with GitHub Copilot, you might have GitHub Copilot and Cursor installed at the same time. We recommend turning off GitHub Copilot when you want to use Cursor.
由于 Cursor 默认随 GitHub Copilot 一起提供,因此您可能同时安装了 GitHub Copilot 和 Cursor。我们建议您在要使用 Cursor 时关闭 GitHub Copilot。

By default, Cursor takes precedence over GitHub Copilot. If you want to use GitHub Copilot, you can disable Cursor in the settings.
默认情况下,Cursor 优先于 GitHub Copilot。如果要使用 GitHub Copilot,可以在设置中禁用 Cursor。

Advanced Features 高级功能

Tab in Peek 速览中的 Tab 键

You can also use Cursor Tab in the “Go to Definition” or “Go to Type Definition” peek views. This is useful, for example, when adding a new argument to a function call.
您还可以在 “Go to Definition” 或 “Go to Type Definition” 速览视图中使用 Cursor Tab。例如,在向函数调用添加新参数时,这非常有用。
file

We especially enjoy using this in vim in conjunction with gd to, for example, modify a function definition, then fix all of its usages in one go.
我们特别喜欢在 vim 中与 gd 结合使用,例如,修改函数定义,然后一次性修复其所有用法。

Cursor Prediction 光标预测

Cursor can also predict where you will go to after an accepted edit. If available, you will be able to press tab to go to the next location, allowing you to tab-tab-tab through edits.
Cursor 还可以预测您在接受编辑后将转到何处。如果可用,您将能够按 Tab 键转到下一个位置,从而允许您通过 Tab-Tab-Tab 键进行编辑。
file

Cursor predicted the next location, and suggested an edit there.
Cursor 预测了下一个位置,并建议在那里进行编辑。

Partial Accepts 部分接受

You can accept the next word of a suggestion by pressing Ctrl/⌘ and the right arrow (or by setting editor.action.inlineSuggest.acceptNextWord to your preferred keybinding).
您可以通过按 Ctrl/⌘ 和向右箭头(或设置为 editor.action.inlineSuggest.acceptNextWord 您喜欢的键绑定)来接受建议的下一个单词。
To enable partial accepts, navigate to Cursor Settings > Features > Cursor Tab.
要启用部分接受,请导航到光标选项卡光标设置功能。

Chat 聊天

Overview 概述

Cursor Chat lets you ask questions or solve problems in your codebase with the most capable language models, all in your editor.
Cursor Chat 允许您使用最强大的语言模型在代码库中提出问题或解决问题,所有这些都在您的编辑器中完成。
file

For language models to give good answers, they need to know specific things that are relevant to your codebase — context.
为了让语言模型给出好的答案,它们需要知道与你的代码库相关的特定事物 — 上下文。

Cursor has several built in features to provide context in chat, such as automatically including context across your entire codebase, searching the web, indexing documentation, and user-specified references to code blocks. They are built to eliminate the tedious copy-pasting otherwise necessary for working with language models on code.
Cursor 具有多项内置功能,可在聊天中提供上下文,例如自动包含整个代码库中的上下文、搜索 Web、为文档编制索引以及用户指定的代码块引用。它们旨在消除在代码上使用语言模型所需的繁琐复制粘贴。

By default, Cursor Chat is in the AI pane, which is on the opposite side of your primary sidebar. You can toggle the AI pane by pressing Ctrl/⌘ + L, which focuses onto the chat when opened. To submit your query, press Enter.
默认情况下,Cursor Chat (光标聊天) 位于 AI 窗格中,该窗格位于主边栏的另一侧。您可以通过按 Ctrl/⌘ + L 来切换 AI 窗格,打开时将焦点放在聊天上。要提交查询,请按 Enter。

User and AI Messages 用户和 AI 消息

User messages contain the text you type, along with the context you’ve referenced. You can go back to any previous user messages to edit and rerun your queries. This will overwrite any messages after that and regenerate new ones.
用户消息包含您键入的文本以及您引用的上下文。您可以返回任何以前的用户消息来编辑和重新运行查询。这将覆盖此后的所有消息并重新生成新消息。

AI messages are the responses generated from the AI model you’ve picked. They are paired with the user message before them. AI messages may contain parsed code blocks which can be added to your codebase with instant apply.
AI 消息是您选择的 AI 模型生成的响应。它们与前面的用户消息配对。AI 消息可能包含已解析的代码块,这些代码块可以通过即时应用添加到您的代码库中。

All user/AI messages together in the same thread are called a chat thread, and each chat thread is saved in your chat history.
同一线程中的所有用户/AI 消息称为聊天线程,每个聊天线程都保存在您的聊天历史记录中。

Chat History 聊天记录

By pressing on the “Previous Chats” button on the top right of the AI pane, or by pressing Ctrl/⌘ + Alt/Option + L, you can see the chat history. You can click on any chat thread to go back and see the messages that make up that thread, and you can also modify the title of the thread by clicking the pen icon, or delete the thread by clicking the garbage can icon upon hovering over the thread in the history.
通过按 AI 窗格右上角的“以前的聊天”按钮,或按 Ctrl/⌘ + Alt/Option + L,您可以查看聊天记录。您可以单击任何聊天线程返回并查看组成该线程的消息,还可以通过单击笔图标来修改线程的标题,或者在将鼠标悬停在历史记录中的线程上时通过单击垃圾桶图标来删除线程。

The title of a Cursor thread is just the first few words of the first user message.
Cursor 线程的标题只是第一条消息的前几个单词。

Default Context 默认上下文

By default, Cursor Chat includes the current file as context. You can submit a query without including any context by pressing Alt/Option Enter on submit, or turn on Default to no context under Cursor Settings > Features > Chat. Chats that begin with a no-context request will not add context for any messages.
默认情况下,Cursor Chat 将当前文件作为上下文。您可以通过在提交时按 Alt/Option Enter 来提交查询,而不包含任何上下文,或者在光标设置 > 聊天功能 > 下打开默认为无上下文。 以 no-context 请求开头的聊天不会为任何消息添加上下文。

As you type, you can see what will be included in context in the pills below the input box.
键入时,您可以在输入框下方的胶囊中看到上下文中将包含的内容。

Adding Context 添加上下文

By default, user messages will contain the text you type, along with the context you’ve referenced. You can add more custom context to each bubble with @ symbols, and by default, the current viewing file will be used as context as well in the user message.
默认情况下,用户消息将包含您键入的文本以及您引用的上下文。您可以使用 @ 符号向每个气泡添加更多自定义上下文,默认情况下,当前查看文件也将用作用户消息中的上下文。

AI Fix in Chat 聊天中的 AI 修复

A convenient feature to fix linter errors in your codebase is to use the AI fix in chat. To do this, hover over the error in the editor, and click the blue AI fix button that shows up.
修复代码库中的 Linter 错误的一个便捷功能是在聊天中使用 AI 修复。为此,请将鼠标悬停在编辑器中的错误上,然后单击显示的蓝色 AI 修复按钮。
The keyboard shortcut for this would be to do Ctrl/⌘ + Shift + E.
键盘快捷键是执行 Ctrl/⌘ + Shift + E。
file

Long Context Chat (Beta) 长时间聊天 (Beta 版)

You can enable long context chat by going to Cursor Settings > Beta > Long Context Chat. With this enabled, you can toggle different chat modes through Ctrl/⌘ ..
您可以通过转到 Cursor Settings > Beta > Long Context Chat 来启用长上下文聊天。启用此功能后,您可以通过Ctrl/⌘切换不同的聊天模式。
Long context chat allows you to include entire folders as context, since the supported models have a larger context window. Check out more about the long context only models here.
长上下文聊天允许您将整个文件夹作为上下文包含在内,因为支持的模型具有更大的上下文窗口。在此处查看有关仅长上下文模型的更多信息。

Customize 自定义

Choose an AI Model 选择 AI 模型

Pick your preferred AI model through the model toggle, and Cursor Chat will use that model to generate responses. You can toggle between models by pressing Ctrl/⌘ /.
通过模型切换选择您喜欢的 AI 模型,Cursor Chat 将使用该模型生成响应。您可以通过按 Ctrl/⌘ / 在模型之间切换。

By default, Cursor Chat uses OpenAI’s GPT-4 for its AI model (specifically, the gpt-4 label points to our instance of GPT4-Turbo).
默认情况下,Cursor Chat 将 OpenAI 的 GPT-4 用于其 AI 模型(具体来说,gpt-4 标签指向我们的 GPT4-Turbo 实例)。

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.
您为 Chat 选择的 AI 模型将保存以供将来使用,因此您不必在每次打开 Cursor Chat 时都更改它。
file

In-Editor 编辑器内

Cursor Chat can also be used as an editor tab by clicking on the horizontal “More” button, and then clicking on the “Open Chat in Editor” button. Cursor Chat will then behave as a regular editor tab. Pressing Ctrl/⌘ + L will bring up the chat tab and focus onto it.
Cursor Chat 也可以用作编辑器选项卡,方法是单击水平的 “More” 按钮,然后单击 “Open Chat in Editor” 按钮。然后,Cursor Chat 将像常规编辑器选项卡一样运行。按 Ctrl/⌘ + L 将调出聊天选项卡并聚焦于它。

Settings 设置

You can customize the Cursor Chat under Cursor Settings > Features > Chat.
您可以在 Cursor Settings > Features > Chat 下自定义光标聊天。
These settings include: 这些设置包括:

  • Always search the web for answers.
    始终在网上搜索答案。

    • This will make the AI model browse the web each query for the most up-to-date information.
      这将使 AI 模型在每个查询中浏览 Web 以获取最新信息。
  • Add chat fading animation.
    添加聊天淡入淡出动画。

    • This adds a smooth animation to the AI messages as they are generated.
      这会在生成 AI 消息时为其添加平滑的动画。
  • Default to no context. 默认为无上下文。
    • This will make the AI model only use the user message as context, and no additional context such as current file will be included.
      这将使 AI 模型仅使用用户消息作为上下文,并且不会包含其他上下文,例如当前文件。
  • Auto scroll chat. 自动滚动聊天。
    • This will automatically scroll the chat as the AI generates text when at the bottom of the thread.
      这将在 AI 在线程底部生成文本时自动滚动聊天。
  • Narrow scrollbar in the chat pane.
    在聊天窗格中缩小滚动条。
  • Show chat history when starting a new chat.
    开始新聊天时显示聊天历史记录。

With Codebase 使用代码库

Default Codebase Chat 默认代码库聊天

If a codebase isn’t indexed, Cursor Chat will first attempt to compute a few search queries to be used to search across your codebase. For better accuracy, it’s recommended to use embeddings search.
如果代码库未编入索引,Cursor Chat 将首先尝试计算一些搜索查询,用于搜索代码库。为了提高准确性,建议使用嵌入搜索。
file

Embeddings Search 嵌入搜索

With codebase indexing, Cursor Chat can accurately generate responses based on your codebase.
通过代码库索引,Cursor Chat 可以根据您的代码库准确生成响应。

By pressing Ctrl/⌘ + Enter after typing a message, Cursor Chat scans through your indexed codebase to find pieces of relevant code. This is generally good for quickly including code snippets to be taken into the context of the conversation. For more control over the codebase search and better accuracy, you can use @codebase.
通过在键入消息后按 Ctrl/⌘ + Enter,Cursor Chat 会扫描您的索引代码库以查找相关代码片段。这通常有利于快速包含要纳入对话上下文中的代码片段。要更好地控制代码库搜索并提高准确性,您可以使用 @codebase。
file

Advanced Codebase Search 高级代码库搜索

Cursor codebase chat goes through a more detailed search when @Codebase is used.
使用 Cursor 代码库聊天时,@Codebase 会进行更详细的搜索。

Apply 应用

Read more about how we built instant apply in our blog post.
在我们的博客文章中阅读更多关于我们如何构建即时申请的信息。
Cursor’s Apply allows you to quickly integrate a codeblock suggestion from the chat into your code.
Cursor 的 Apply 允许您将聊天中的代码块建议快速集成到您的代码中。

Apply Code Blocks 应用代码块

To apply a code block suggestion, you can press on the play button in the top right corner of each chat code block.
要应用代码块建议,您可以按每个聊天代码块右上角的播放按钮。
file

This will edit your file to incorporate the code produced by Chat. Since you can add the most context and have the most back-and-forth with the model in Chat, we recommend Chat + Apply for more complex AI-driven code changes.
这将编辑您的文件以合并 Chat 生成的代码。由于您可以在 Chat 中添加最多的上下文并与模型进行最多的来回交流,因此我们建议使用 Chat + Apply 进行更复杂的 AI 驱动的代码更改。

Accept or Reject 接受或拒绝

Once you have applied a code block, you can go through the diffs and accept or reject the changes. You can also click on the “Accept” or “Reject” buttons in the top right corner of the chat code block.
应用代码块后,您可以浏览差异并接受或拒绝更改。您也可以点击聊天代码块右上角的“接受”或“拒绝”按钮。
Ctrl/⌘ Enter to accept, Ctrl/⌘ Backspace to reject.
Ctrl/⌘ Enter 键接受,Ctrl/⌘ Backspace 键拒绝。
file

Terminal Cmd K 终端 Cmd K

Overview 概述

Cmd K, also known or “Ctrl K” on Windows/Linux, allows you to generate new code or edit existing code in the editor window.
Cmd K,在 Windows/Linux 上也称为“Ctrl K”,允许您在编辑器窗口中生成新代码或编辑现有代码。
file

Prompt Bars 提示栏

In Cursor, we call the bar that appears when you press Ctrl/Cmd K the “Prompt Bar”. It works similarly to the AI input box for chat, in which you can type normally, or use @ symbols to reference other context.
在 Cursor 中,我们将按 Ctrl/Cmd K 时出现的栏称为“Prompt Bar”。它的工作原理类似于用于聊天的 AI 输入框,您可以在其中正常键入,或使用 @ 符号引用其他上下文。

Inline Generation 内联生成

If no code is selected when you press Ctrl/Cmd K, Cursor will generate new code based on the prompt you type in the prompt bar.
如果在按 Ctrl/Cmd K 时未选择任何代码,Cursor 将根据您在提示栏中键入的提示生成新代码。
file

Inline Edits 内联编辑

For in-place edits, you can simply select the code you want to edit and type into the prompt bar.
对于就地编辑,您只需选择要编辑的代码,然后在提示栏中键入即可。
file

Follow-up Instructions 后续操作说明

After each generation, you can further refine the prompt by adding more instructions to the prompt bar, and pressing Enter so the AI regenerates based on your follow-up instructions.
每次生成后,您可以通过向提示栏添加更多说明,然后按 Enter 键,以便 AI 根据您的后续说明重新生成,从而进一步优化提示。

Default Context 默认上下文

By default, Cursor will try to find different kinds of useful information to improve code generation, in addition to the manual @ symbols you include.
默认情况下,除了您包含的手动 @ 符号之外,Cursor 还将尝试查找不同类型的有用信息来改进代码生成。
Additional context may include related files, recently viewed files, and more. After gathering, Cursor ranks the context items by relevance to your edit/generation and keeps the top items in context for the large language model.
其他上下文可能包括相关文件、最近查看的文件等。收集后,Cursor 按与编辑/生成的相关性对上下文项进行排名,并将排名靠前的项目保留在大型语言模型的上下文中。

Quick Question 快速问题

If you press Option/Alt Enter while in the prompt bar, Cursor will respond to any questions you have about the selection, and the context you have attached.
如果在提示栏中按 Option/Alt Enter,则 Cursor 将回答您关于选择和附加上下文的任何问题。
The contents of this conversation could be further used in follow-up generations, so you could simply type “do it” after Cursor comes up with a response to generate the code after a quick question.
此对话的内容可以在后续生成中进一步使用,因此您只需在 Cursor 提出响应后键入“do it”即可在快速提问后生成代码。

终端 Cmd K

In the built-in Cursor terminal, you can press Ctrl/⌘ K to open a prompt bar on the bottom of the terminal. This prompt bar allows you to describe your desired action in the terminal, and terminal Cmd K will generate a command. You can accept the command by hitting esc or run the command immediately with Ctrl/⌘ + Enter.
在内置的 Cursor 终端中,您可以按 Ctrl/⌘ K 打开终端底部的提示栏。此提示栏允许您在终端中描述所需的操作,终端 Cmd K 将生成一个命令。您可以通过按 esc 接受命令,也可以立即使用 Ctrl/⌘ + Enter 运行命令。
file

By default, Terminal Cmd K sees your recent terminal history, your instructions, and anything else you put in the prompt bar as context.
默认情况下,终端 Cmd K 会看到您最近的终端历史记录、您的指令以及您作为上下文放入提示栏中的任何其他内容。

Context 上下文

Codebase Indexing 代码库索引

Index your Codebase 为代码库编制索引

For better and more accurate codebase answers using @codebase or Ctrl/⌘ Enter, you can index your codebase. Behind the scenes, Cursor computes embeddings for each file in your codebase, and will use these to improve the accuracy of your codebase answers.
要使用 @codebase 或 Ctrl/⌘ Enter 更好、更准确的代码库答案,您可以为您的代码库编制索引。在幕后,Cursor 会计算代码库中的每个文件的嵌入向量,并将使用这些嵌入向量来提高代码库答案的准确性。

Your codebase index will automatically synchronize with your latest codebase changes.
您的代码库索引将自动与您的最新代码库更改同步。

The status of your codebase indexing is under Cursor Settings > Features > Codebase Indexing.
代码库索引的状态位于 Cursor Settings > Features Codebase Indexing 下。
file

Advanced Settings 高级设置

By default, Cursor will index all files in your codebase if privacy mode is not enabled.
默认情况下,如果未启用隐私模式,Cursor 将索引代码库中的所有文件。

You can also expand the Show Settings section to access more advanced options. Here, you can decide whether you want to enable automatic indexing for new repositories and configure the files that Cursor will ignore during repository indexing, in addition to your .gitignore settings.
您还可以展开 Show Settings (显示设置) 部分以访问更多高级选项。在这里,除了 .gitignore 设置之外,您还可以决定是否要为新存储库启用自动索引,并配置 Cursor 在存储库索引期间将忽略的文件。

If you have any large content files in your project that the AI definitely doesn’t need to read, ignoring those files could improve the accuracy of the answers.
如果您的项目中有任何 AI 绝对不需要读取的大型内容文件,则忽略这些文件可以提高答案的准确性。

Rules for AI AI 规则

You can add custom instructions to Cursor by modifying the Rules for AI section under Cursor Settings > General > Rules for AI.
您可以通过修改 Cursor Settings 下的 Rules for AI 部分来向 Cursor 添加自定义指令> General > Rules for AI。

This custom instruction will be included for features such as Cursor Chat and Ctrl/⌘ K.
此自定义说明将包含在 Cursor Chat 和 Ctrl/⌘ K 等功能中。
file

.cursorrules

For project-specific instructions, you can include the instructions in a .cursorrules file in the root of your project.
对于特定于项目的说明,您可以将说明包含在项目根目录的 .cursorrules 文件中。
As the same as the “Rules for AI” section, the instructions in the .cursorrules file will be included for features such as Cursor Chat and Ctrl/⌘ K.
与“AI 规则”部分相同,.cursorrules 文件中的说明将包含在 Cursor Chat 和 Ctrl/⌘ K 等功能中。

@ Symbols @ 符号

详见:@符号使用篇

Ignore Files 忽略文件

To ignore files to be included in Cursor features such as codebase indexing, you can use a .cursorignore file in the root of your project. It works the same way as .gitignore works for git.
要忽略要包含在 Cursor 功能(如代码库索引)中的文件,您可以在项目的根目录中使用 .cursorignore 文件。它的工作方式与 .gitignore 对 git 的工作方式相同。

.cursorignore respects .gitignore. If you already have .gitignore, the files will be ignored by default. If you want to ignore additional files, you can add them to the .cursorignore file.
.cursorignore 遵循 .gitignore 。如果你已经有 .gitignore,默认情况下将忽略这些文件。如果要忽略其他文件,可以将它们添加到 .cursorignore 文件中。

An Example

示例 .cursorignore 文件

# Ignore all files in the `dist` directory
dist/

# Ignore all `.log` files
*.log

# Ignore specific file `config.json`
config.json

Advanced 高级功能

Models 模型

With Cursor Chat, Ctrl/⌘ K, and Terminal Ctrl/⌘ K, you can easily switch between different models of your choice.
使用光标聊天、Ctrl/⌘ K 和终端 Ctrl/⌘ K,您可以轻松地在您选择的不同模型之间切换。

Model Dropdown 模型下拉列表

Underneath the AI input box, you will see a dropdown that allows you to select the model you want to use. By default, Cursor has these models ready to use:
在 AI 输入框下方,您将看到一个下拉列表,允许您选择要使用的模型。默认情况下,Cursor 已准备好使用这些模型:

  • GPT-4o GPT-4o
  • GPT-4 GPT-4
  • Claude 3.5 Sonnet
  • cursor-small
    • cursor-small is Cursor’s custom model that isn’t as smart as GPT-4, but is faster and users have unlimited access to it.

cursor-small 是 Cursor 的自定义模型,它不如 GPT-4 智能,但速度更快,用户可以无限制地访问它。

You can add additional models under Cursor Settings > Models > Model Names.
您可以在 Cursor Settings > Models > Model Names 下添加其他模型。
file

Long Context Only Models 仅长上下文模型

In long context chat, the model selection is limited to the models that support long context:
在长上下文聊天中,模型选择仅限于支持长上下文的模型:

  • gpt-4o-128k
  • gemini-1.5-flash-500k
  • claude-3-haiku-200k
  • claude-3-sonnet-200k
  • claude-3-5-sonnet-200k

What context window is used for model X?

模型 X 使用什么上下文窗口?

In chat, we limit to around 20,000 tokens at the moment (or less if the model does not support that much context). For cmd-K, we limit to around 10,000 tokens, to balance TTFT and quality. Long-context chat uses the model’s maximum context window.
在聊天中,我们目前限制在 20,000 个令牌左右(如果模型不支持那么多上下文,则更少)。对于 cmd-K,我们限制在 10,000 个左右的 Token,以平衡 TTFT 和质量。长上下文聊天使用模型的最大上下文窗口。

Custom API Keys 自定义 API 密钥

OpenAI API Keys OpenAI API 密钥

Cursor lets you input your own OpenAI API key to send as many AI messages as you want at your own cost.
Cursor 允许您输入自己的 OpenAI API 密钥,以自费发送任意数量的 AI 消息。

You can get your own API key from here. To use your own API key, go to Cursor Settings > Models > OpenAI API Key and enter your API key. Then, click on the “Verify” button. Once your key is validated, your OpenAI API key will be enabled.
您可以从此处获取自己的 API 密钥。要使用您自己的 API 密钥,请转到 OpenAI API 密钥> 模型的光标设置 并输入您的 API 密钥。然后,单击“验证”按钮。验证密钥后,您的 OpenAI API 密钥将被启用。
file

Anthropic API Keys Anthropic API 密钥

Similar to OpenAI, you can also set your own Anthropic API key so that you will be using claude-based models at your own cost.
与 OpenAI 类似,您还可以设置自己的 Anthropic API 密钥,以便自费使用基于 claude 的模型。
file

Google API Keys Google API 密钥

For Google API keys, you can set your own API key so that you will be using Google models such as gemini-1.5-flash-500k at your own cost.
对于 Google API 密钥,您可以设置自己的 API 密钥,以便自费使用 gemini-1.5-flash-500k 等 Google 模型。
file

Azure Integration Azure 集成

Finally, you can also set your own Azure API key so that you will be using Azure OpenAI models at your own cost.
最后,您还可以设置自己的 Azure API 密钥,以便自费使用 Azure OpenAI 模型。
file

Will my API key be stored or leave my device?

我的 API 密钥会被存储还是离开我的设备?

Your API key will not be stored, but it will be sent up to our server with every request. All requests are routed through our backend, because that’s where we do the final prompt building.
您的 API 密钥不会被存储,但会随每个请求一起发送到我们的服务器。所有请求都通过我们的后端路由,因为这是我们进行最终 prompt 构建的地方。

Shadow Workspace 影子工作区

The shadow workspace is an opt-in setting you can configure to improve the quality of AI-generated code. Only some features use it.
影子工作区是一个可选设置,您可以配置以提高 AI 生成的代码的质量。只有部分功能使用它。
file

If you have the shadow workspace enabled, background AIs can ask for lints for the code they write. This spawns a hidden window locally on your computer, to ensure that your coding experience is unaffected.
如果您启用了影子工作区,后台 AI 可以请求他们编写的代码的 lint。这会在您的计算机上本地生成一个隐藏窗口,以确保您的编码体验不受影响。

The shadow workspace will increase the memory usage from Cursor, so we recommend only enabling this feature if you have plenty of RAM.
影子工作区将增加 Cursor 的内存使用量,因此我们建议仅在您有大量 RAM 时才启用此功能。

Privacy 隐私

Privacy FAQ 隐私常见问题

什么是隐私模式?

With Privacy Mode, none of your code will ever be stored by us or any third-party (except for OpenAI which persists the prompts we send to them for 30 days for trust and safety, unless you’re on the business plan). Otherwise, we may save prompts / collect telemetry data to improve Cursor.
使用隐私模式,我们或任何第三方都不会存储您的任何代码(OpenAI 除外,为了保证信任和安全,OpenAI 会将我们发送给他们的提示保留 30 天,除非您在商业计划中)。否则,我们可能会保存提示/收集遥测数据以改进 Cursor。

You can enable Privacy Mode under Cursor Settings > General > Privacy Mode.
您可以在 Cursor Settings 下启用 Privacy Mode(隐私模式),> General(常规)> Privacy Mode(隐私模式)。
file

请求是否始终通过 Cursor 后端路由?

Yes! Even if you use your API key, your requests will still go through our backend! That’s where we do our final prompt building.
是的!即使您使用 API 密钥,您的请求仍将通过我们的后端!这就是我们进行最后的提示构建的地方。

为代码库编制索引是否需要存储代码?

It does not! If you choose to index your codebase, Cursor will upload your codebase in small chunks to our server to compute embeddings, but all plaintext code ceases to exist after the life of the request.
它没有!如果您选择为代码库编制索引,Cursor 会将您的代码库以小块上传到我们的服务器以计算嵌入,但所有纯文本代码在请求生命周期后都不复存在。

The embeddings and metadata about your codebase (hashes, file names) are stored in our database, but none of your code is.
有关您的代码库的嵌入和元数据(哈希、文件名)存储在我们的数据库中,但您的任何代码都不是。

Troubleshooting 故障排除

Common Issues 常见问题

我在更改日志上看到更新,但 Cursor 不会更新。

If the update is very new, it might not have rolled out to you yet. We do staged rollouts, which means we release new updates to a few randomly selected users first before releasing them to everyone. Typically, reaching all users takes around 5 hours from the first user. For larger updates, it can take longer.
如果更新非常新,则可能尚未向您推出。我们进行分阶段推出,这意味着我们先向一些随机选择的用户发布新更新,然后再将其发布给所有人。通常,从第一个用户开始,大约需要 5 小时才能联系所有用户。对于较大的更新,可能需要更长的时间。

If you don’t want to wait, you can redownload Cursor from our homepage. You’ll likely receive the latest update instantly. Don’t worry, all of your settings, extensions, etc., will transfer to the redownloaded version. You don’t have to uninstall the existing version first.
如果您不想等待,您可以从我们的主页重新下载 Cursor。您可能会立即收到最新更新。不用担心,您的所有设置、扩展等都将转移到重新下载的版本。您不必先卸载现有版本。

我在 Cursor 中登录 GitHub 时遇到问题 / 如何在 Cursor 中注销 GitHub?

You can try using the Sign Out of GitHub command from the command palette Ctrl/⌘ + Shift + P.
您可以尝试使用命令面板中的 Sign Out of GitHub 命令 Ctrl/⌘ + Shift + P。

我无法使用 GitHub Codespaces。

Unfortunately, we don’t support GitHub Codespaces yet.
遗憾的是,我们尚不支持 GitHub Codespaces。

我在连接到远程 SSH 时遇到错误。

Currently, we don’t support SSHing into Mac or Windows machines. If you’re not using a Mac or Windows machine, please report your issue to us in the forum. It would be helpful to include some logs for better assistance.
目前,我们不支持通过 SSH 连接到 Mac 或 Windows 计算机。如果您未使用 Mac 或 Windows 计算机,请在论坛中向我们报告您的问题。包含一些日志以获得更好的帮助会很有帮助。

Cursor Tab 和 Cmd K 在我的公司代理后面不起作用。

Cursor Tab and Cmd K use HTTP/2 by default, which allows us to use less resources with lower latency. Some corporate proxies (e.g. Zscaler in certain configurations) block HTTP/2. To fix this, you can set "cursor.general.disableHttp2": true in the settings (Cmd/Ctrl + , and then search for http2).
Cursor Tab 和 Cmd K 默认使用 HTTP/2,这使我们能够使用更少的资源和更低的延迟。某些公司代理(例如某些配置中的 Zscaler)会阻止 HTTP/2。要解决这个问题,你可以在设置 "cursor.general.disableHttp2": true 中设置(Cmd/Ctrl + ,然后搜索 http2)。

我刚刚订阅了 Pro,但我仍然在应用程序中使用免费计划。

Try logging out and logging back in from the Cursor Settings Popup.
尝试从 Cursor Settings 弹出窗口注销并重新登录。

我的使用量何时会再次重置?

If you’re subscribed to Pro you can click on Manage Subscription from the Dashboard and your plan renewal date will be displayed at the top.
如果您订阅了 Pro,则可以单击仪表板中的“管理订阅”,您的计划续订日期将显示在顶部。
If you’re a free user you can check when you got the first email from us in your inbox. Your usage will reset every month from that date.
如果您是免费用户,则可以查看收件箱中收到我们的第一封电子邮件的时间。从该日期开始,您的使用量将每月重置。

如何卸载 Cursor?

You can follow this guide to uninstall Cursor. Replace every occurrence of “VS Code” or “Code” with “Cursor”, and “.vscode” with “.cursor”.
您可以按照本指南卸载 Cursor。将“VS Code”或“Code”替换为“Cursor”,将“.vscode”替换为“.cursor”。

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。