Cursor deeply integrates AI into your coding workflow. Let's explore the primary ways you'll interact with its intelligent suggestions to boost your productivity.
As you type, Cursor offers context-aware code completions (often multi-line) directly in your editor as greyed-out "ghost text." Simply press Tab to accept the full suggestion.
# User types:
def calculate_average(numbers):
# Cursor suggests (ghost text):
if not numbers:
return 0
return sum(numbers) / len(numbers)
# Press Tab to accept
Type / anywhere in your code to access commands for generating, explaining, documenting, or transforming code. Each command is specialized for specific tasks.
// User types / and selects:
/explain
// followed by selecting code to explain
// Or generating code with:
/generate
// followed by a description of what to create
The AI chat panel provides a conversational interface for complex queries, explanations, and code generation. Use it when you need deeper context or multi-step help.
User: How can I optimize this function for better performance?
AI: Based on your current implementation, here are 3 optimizations:
1. Cache the results to prevent recalculation
2. Use a more efficient algorithm (details...)
3. Refactor the nested loops into a single operation
Highlight code and use the keyboard shortcut to access contextual AI actions like explain, document, fix/improve, or test generation.
// Select this React component
function UserProfile({ userId, showDetails = false }) {
const [user, setUser] = useState(null);
useEffect(() => {
fetchUser(userId).then(data => setUser(data));
}, [userId]);
// Press Cmd+I/Ctrl+I for actions like:
// - Explain code
// - Document function
// - Generate tests
// - Improve code
}
When encountering errors, select the error message or problematic code and press Cmd+I/Ctrl+I. Choose "Fix" from the menu to get AI-powered solutions.
// Error example
const users = getUsers();
console.log(users.length);
// TypeError: Cannot read property 'length' of undefined
// 1. Select the error message or code
// 2. Press Cmd+I/Ctrl+I and select "Fix"
// 3. AI suggests:
const users = getUsers() || [];
console.log(users.length);