Cursor AI IDE Complete Guide
Cursor AI IDE: Complete Setup and Usage Guide
Cursor is an AI-powered code editor built on top of Visual Studio Code that integrates large language models directly into your development workflow. It supports models from multiple providers including Claude, GPT, and Gemini, allowing you to write, edit, debug, and understand code faster with AI assistance. This guide covers everything from initial setup to advanced usage patterns.
Installation
Download Cursor from cursor.com for your operating system (macOS, Windows, or Linux). The installer handles everything automatically. If you are migrating from VS Code, Cursor can import your extensions, settings, and keybindings during the setup process.
- Download and install Cursor from the official website.
- Launch Cursor and sign in with your account (Google, GitHub, or email).
- When prompted, choose to import VS Code settings if you are migrating.
- Select your preferred AI model and configure your API key if using a custom provider.
Understanding Cursor's AI Features
Cursor provides several distinct AI interaction modes, each designed for different tasks:
Tab Completion
Cursor predicts the next code you want to write as you type. Press Tab to accept suggestions. This works for single lines, multi-line completions, and even multi-cursor edits. Tab completion is context-aware and considers your open files, recent edits, and project structure.
Inline Edit (Ctrl+K / Cmd+K)
Select a block of code and press Ctrl+K (or Cmd+K on macOS) to edit it with a natural language instruction. This is ideal for targeted modifications like refactoring a function, adding error handling, or converting code between patterns:
// Select this function, press Cmd+K, and type:
// "Add input validation and error handling"
function processOrder(order) {
const total = order.items.reduce((sum, item) => sum + item.price, 0);
return { orderId: order.id, total };
}
Chat Panel (Ctrl+L / Cmd+L)
Open the chat panel for longer conversations about your code. You can ask questions, request explanations, plan architecture changes, and more. Use @ to reference specific files, folders, or documentation:
// In the chat panel:
@src/auth.js Explain the authentication flow and suggest improvements
@docs/api-spec.md Generate route handlers that match this API specification
Agent Mode (Ctrl+I / Cmd+I)
Agent mode is Cursor's most powerful feature. It can autonomously make changes across multiple files, run terminal commands, and iterate on its work based on error feedback. Use it for larger tasks like implementing features, fixing complex bugs, or performing project-wide refactors.
Configuring AI Models
Cursor comes with built-in access to several models through its Pro subscription. You can also configure custom API keys for direct access to model providers:
- Open Settings (
Cmd+,orCtrl+,). - Navigate to Cursor Settings and then Models.
- Under "Model Configuration," you can add API keys for OpenAI, Anthropic, Google, and other providers.
- For custom API endpoints, configure the base URL to point to your provider or relay service.
Using Custom API Endpoints
If you want to use a relay service or self-hosted model, configure the base URL in Cursor settings:
// In Cursor Settings > Models > OpenAI API Key section:
Base URL: https://claude4u.com/v1
API Key: your-relay-api-key
This routes all API requests through the specified endpoint, allowing you to use services like claude4u.com for model access with benefits like load balancing, cost tracking, and reliable access from any region.
Essential Keyboard Shortcuts
Tab— Accept AI suggestionEsc— Dismiss AI suggestionCmd+K/Ctrl+K— Inline edit with AICmd+L/Ctrl+L— Open AI chat panelCmd+I/Ctrl+I— Open Agent modeCmd+Shift+L— Add selection to chat context@file— Reference a file in chat@folder— Reference an entire folder in chat
Project Rules with .cursorrules
Create a .cursorrules file in your project root to give Cursor persistent context about your project's conventions, tech stack, and coding standards:
You are working on a Node.js Express API with TypeScript.
- Use async/await for all asynchronous operations
- Follow REST conventions for route naming
- Use Zod schemas for input validation
- Write Jest tests for all new functions
- Use the repository pattern for database access
- Error responses should follow RFC 7807 Problem Details format
Tips for Getting the Most Out of Cursor
- Use context references liberally. The
@syntax for referencing files and folders dramatically improves AI response quality. - Write clear, specific instructions. "Add pagination to the user list endpoint with offset and limit parameters" works better than "improve the user endpoint."
- Review all AI-generated code. AI is a powerful assistant but is not infallible. Always review changes before committing.
- Iterate in conversation. If the first response is not quite right, refine your request rather than starting over.
- Keep your project indexed. Cursor builds a code index for better context. Let it finish indexing before asking complex questions about your codebase.
Get Started with 轻舟 AI
Stable, fast AI API relay — supports Claude, OpenAI, Gemini and more
Sign Up Free
轻舟 AI