Cursor Cheat Sheet - 快速参考指南,收录常用语法、命令与实践。
| Feature | Description |
|---|---|
| Tab | Smart code completion |
| Chat | AI conversation assistant |
| Composer | Multi-file editing |
| @ References | Reference files/code/docs |
| Shortcut | Action |
|---|---|
Cmd/Ctrl + K | Inline edit (Cmd K) |
Cmd/Ctrl + L | Open Chat panel |
Cmd/Ctrl + I | Open Composer |
Cmd/Ctrl + Shift + I | Composer (fullscreen) |
Tab | Accept AI completion |
Esc | Cancel AI completion |
Cmd/Ctrl + → | Accept partial (word by word) |
| Shortcut | Action |
|---|---|
Cmd/Ctrl + Shift + K | Delete current line |
Cmd/Ctrl + Enter | Insert line below |
Cmd/Ctrl + Shift + Enter | Insert line above |
Alt + ↑/↓ | Move line |
Alt + Shift + ↑/↓ | Copy line |
| Shortcut | Action |
|---|---|
Cmd/Ctrl + P | Quick open file |
Cmd/Ctrl + Shift + P | Command palette |
Cmd/Ctrl + G | Go to line |
Cmd/Ctrl + Shift + O | Go to symbol |
F12 | Go to definition |
Shift + F12 | Find references |
| Shortcut | Action |
|---|---|
Alt + Click | Add cursor |
Cmd/Ctrl + Alt + ↑/↓ | Add cursor above/below |
Cmd/Ctrl + D | Select next match |
Cmd/Ctrl + Shift + L | Select all matches |
| Shortcut | Action |
|---|---|
Cmd/Ctrl + F | Find in file |
Cmd/Ctrl + H | Replace in file |
Cmd/Ctrl + Shift + F | Global search |
Cmd/Ctrl + Shift + H | Global replace |
Cmd/Ctrl + L
Or click the Chat icon in sidebar
File Reference
@filename.ts
Explain what this file does
Symbol Reference
@functionName
What's wrong with this function?
Folder Reference
@src/components
Analyze the code structure in this directory
Documentation Reference
@Docs
Look up React hooks documentation
Web Reference
@Web
Search for latest TypeScript 5.0 features
Git Reference
@Git
What changed in recent commits?
Codebase Reference
@Codebase
Where is user authentication implemented?
Code Explanation
Explain what this code does and why
Bug Finding
What bugs are in this code? How do I fix them?
Performance
How can I optimize this code for better performance?
Generate Tests
Write unit tests for this function
Add Comments
Add detailed comments to this code
Refactor
Refactor this to follow best practices
Cmd/Ctrl + KRefactor
Refactor using clearer variable names
Add Types
Add TypeScript type annotations
Error Handling
Add error handling and edge case checks
Optimize
Optimize for better performance
Simplify
Simplify this code
Convert to Async
Convert to async/await syntax
Extract Function
Extract this logic into a separate function
Add Validation
Add input validation
Make Reusable
Make this more reusable and generic
Generate at empty line with Cmd/Ctrl + K:
React Component
Create a React component that displays a user profile card
with name, avatar, and bio
Utility Function
Write a function to validate email format
using regex
API Handler
Create an Express route handler for user registration
with validation and error handling
Algorithm
Implement binary search algorithm
with TypeScript generics
Esc to cancelCmd/Ctrl + Z to undoCmd/Ctrl + I
Fullscreen mode:
Cmd/Ctrl + Shift + I
New Feature
Create a user authentication feature including:
- Login form component
- API route handler
- State management
- Form validation
- Error handling
CRUD Operations
Create a full CRUD API for blog posts:
- Model definition
- API routes (GET, POST, PUT, DELETE)
- Input validation
- Error responses
Component Split
Split this large component into smaller
sub-components, each in its own file:
- Header section
- Content area
- Footer section
Add Tests
Add comprehensive unit tests for all functions
in the src/utils directory using Jest
Migration
Migrate this JavaScript code to TypeScript:
- Add type definitions
- Create interfaces
- Update imports
| Action | Shortcut |
|---|---|
| Accept all | Tab |
| Accept word by word | Cmd/Ctrl + → |
| Cancel | Esc |
Good Comments
// Calculate days between two dates
// Returns negative if date2 is before date1
function daysBetween(date1, date2) {
Clear Function Signature
function validateEmail(email: string): boolean {
Related Context
const users = await fetchUsers();
// Completion will be more accurate
const activeUsers = users.filter(
Cmd/Ctrl + ,)Privacy Mode
"cursor.privacy.mode": "enabled"
Autocomplete Delay
"cursor.autocomplete.delay": 200
Trigger Length
"cursor.autocomplete.triggerLength": 2
Create .cursorrules in project root:
# Project Standards
- Use TypeScript for all new files
- Follow ESLint rules strictly
- Use functional React components
- Style with Tailwind CSS
# Code Style
- Variables: camelCase
- Components: PascalCase
- Files: kebab-case
# Documentation
- JSDoc comments for functions
- Inline comments for complex logic
# Testing
- Jest for unit tests
- React Testing Library for components
- Minimum 80% coverage
@Docs in Chat@file.ts
Review this file for:
1. Code quality issues
2. Potential bugs
3. Performance problems
4. Security vulnerabilities
5. Suggest improvements
@Codebase
Analyze the project architecture:
- What's the overall structure?
- What are the main modules?
- How do they communicate?
- Any architectural concerns?
@src/
I'm new to this project. Explain:
- What does this directory do?
- What are the key files?
- How does data flow through it?
This code throws an error:
<error>
TypeError: Cannot read property 'map' of undefined
</error>
Related code:
@component.tsx
How do I fix this?
I want to add dark mode to this app.
@Codebase
Suggest:
- Which files need changes?
- What's the best approach?
- Any existing patterns to follow?
@component.tsx
This component is 500+ lines.
How should I split it?
- Follow React best practices
- Maintain functionality
- Improve testability
地址
Level 10b, 144 Edward Street, Brisbane CBD(Headquarter)Level 2, 171 La Trobe St, Melbourne VIC 3000四川省成都市武侯区桂溪街道天府大道中段500号D5东方希望天祥广场B座45A13号Business Hub, 155 Waymouth St, Adelaide SA 5000Disclaimer
JR Academy acknowledges Traditional Owners of Country throughout Australia and recognises the continuing connection to lands, waters and communities. We pay our respect to Aboriginal and Torres Strait Islander cultures; and to Elders past and present. Aboriginal and Torres Strait Islander peoples should be aware that this website may contain images or names of people who have since passed away.
匠人学院网站上的所有内容,包括课程材料、徽标和匠人学院网站上提供的信息,均受澳大利亚政府知识产权法的保护。严禁未经授权使用、销售、分发、复制或修改。违规行为可能会导致法律诉讼。通过访问我们的网站,您同意尊重我们的知识产权。 JR Academy Pty Ltd 保留所有权利,包括专利、商标和版权。任何侵权行为都将受到法律追究。查看用户协议
© 2017-2025 JR Academy Pty Ltd. All rights reserved.
ABN 26621887572