在 Cursor 中打开项目
- 确保已安装 git
- 克隆示例项目:
- 补全多行和整段代码
- 在文件内或跨文件跳转到下一个补全建议
- 开始输入函数的开头:
- Tab 的建议会自动出现
- 按 Tab 接受建议
- Cursor 会继续补全参数和函数体
- 选中你刚创建的函数
- 按下 Ctrl+K
- 输入 “make this function calculate fibonacci numbers”
- 按下 Enter 以应用更改
- Cursor 会自动添加 import 和文档
- 打开 Chat 面板(Ctrl+I)
- 输入:“Add tests for this function and run them”
- Agent 会为你创建测试文件、编写测试用例,并运行它们
进阶加分
将工作交给 Background Agent
将工作交给 Background Agent
- 打开 Background Agent 控制面板(Ctrl+E)
- 询问:“Find and fix a bug in this project”
- Background Agent 将:
- 创建远程虚拟机(VM)
- 探索你的项目
- 检测 bug
- 提出修复方案
编写规则
编写规则
- 打开命令面板(Ctrl+Shift+P) 2. 搜索:“New Cursor
Rule” 3. 命名(例如
style-guide
) 4. 选择 Rule Type “Always” 5. 定义 你的规范:Prefer using camelCase for variable names
设置 MCP 服务器
设置 MCP 服务器
- 访问我们的 MCP directory
- 选择一个工具
- 点击 “Install”
- 打开 Cursor 设置(Ctrl+Shift+J)
- 前往 “Tools & Integrations”
- 点击 “New MCP Server”