Cursor AI: Complete Setup and Practical Coding Guide

May 24, 2026guides

What Cursor Is (and What It Isn't)

Cursor is a code editor built as a fork of VS Code. It inherits the full VS Code extension marketplace, keyboard shortcuts, settings system, and file handling — then layers in deep AI integration through a built-in inference client that can call Claude Sonnet, GPT-4.1, and other models.

The key difference from GitHub Copilot is architecture: Copilot is a plugin you add to an existing editor. Cursor is the editor. This lets it index your entire codebase into context, observe your edits across files, and predict multi-line changes with more coherence than inline completions alone can achieve.


Installation

Download from cursor.com — installers are available for macOS, Windows, and Linux.

macOS/Windows: Run the installer directly.

Linux: The download is an .AppImage file. Make it executable and run it:

chmod a+x cursor_2.6.14_x86_64.AppImage
./cursor_2.6.14_x86_64.AppImage

Replace cursor_2.6.14_x86_64 with the actual downloaded filename (versions update frequently; the naming format may differ between architectures, e.g., cursor_2.4.46_arm64.deb on ARM Linux).

On first launch, Cursor prompts for:

  • Keyboard layout — defaults to VS Code shortcuts; keep this unless you're migrating from a different editor
  • AI language — language to use when interacting with the AI assistant
  • Codebase-wide context — enabling this indexes your project for codebase-level questions (recommended for any project with multiple files)

Keyboard Shortcut Reference

Shortcut (macOS)Shortcut (Win/Linux)Action
Cmd+KCtrl+KOpen inline code generator / interact with selected code
Cmd+LCtrl+LOpen the chat panel
TabTabAccept AI autocomplete suggestion
EscEscDismiss autocomplete suggestion
Cmd+Shift+LCtrl+Shift+LAdd selected code to chat context

Feature 1: Inline Code Generation (Cmd+K)

Cmd+K with no selection opens a floating prompt bar. Type a natural language instruction and press Enter to generate:

Add input validation to this function that raises ValueError for negative inputs

Cursor generates the code inline as a diff. Green lines are additions, red lines are removals. Accept with the Accept button, reject with Reject, or modify the prompt to refine.

Interacting with existing code: Select a function or block first, then press Cmd+K. Now Cursor can refactor, explain, add type hints, or rewrite it based on your prompt. The selection becomes part of the prompt context automatically.

Quick questions: With code selected and Cmd+K open, click the Quick Question button instead of Submit Edit to ask a question without making changes (e.g., "Why does this use O(n²) complexity?").


Feature 2: Tab Autocomplete

While typing, Cursor continuously generates multi-line completion suggestions. Press Tab to accept. The suggestions are contextually aware — if you just defined a User dataclass and start writing a function, Cursor predicts the parameter types and return signature.

This also works with plain English. Write a comment describing what you need:

# iterate over all pairs in a list and check if their sum equals target

Cursor suggests the corresponding double-loop implementation. Press Tab to insert.

Unlike simple token completion, Cursor predicts based on recent edits — it knows what you changed 30 seconds ago and uses that as additional context.


Feature 3: Chat Panel (Cmd+L)

The chat panel is more powerful than inline generation for multi-step tasks:

  • Codebase queries — ask questions about the project without selecting code first
  • Multi-file changes — generate edits that span multiple files and apply them all at once
  • Instant Apply — code blocks in the chat have an "Apply" button that diffs the change directly into the active file
  • Model selection — switch between Claude Sonnet, GPT-4.1, and other models mid-conversation

Example codebase query without any selection:

Find all places in this project where user input is passed directly to SQL queries
without parameterization

Cursor scans the indexed codebase and returns matches with file paths.


Feature 4: @ Context Mentions

The @ key in the chat panel opens a context menu with powerful options:

MentionWhat It Adds
@fileAdd a specific file to context
@folderAdd all files in a directory
@codebaseEnable full indexed codebase search
@webFetch live web results (bypasses training cutoff)
@docsReference a documentation URL you've added
@gitInclude a GitHub repository in context

@web example: Cursor's training data has a cutoff. Asking about a library released recently will produce outdated or hallucinated answers. Use @web to pull live documentation:

@web How do I configure streaming responses in the latest Anthropic Python SDK?

@docs for private libraries: Team-internal or lesser-known libraries won't be in Cursor's training data. Add their docs:

  1. In the chat, type @ → select Docs → enter the documentation URL
  2. Name the reference (e.g., "MyInternalLib")
  3. Reference it in future prompts with @MyInternalLib

Documentation references are managed in Settings → Features → Docs.


Feature 5: Custom AI Rules

Cursor lets you define persistent rules that modify the AI's behavior across all requests — no need to repeat the same instructions in every prompt.

Access via Settings → General → Rules for AI. Examples:

Always use type hints in Python function definitions.
Never use `any` in TypeScript — use explicit types or unknown.
All generated SQL must use parameterized queries.
When generating React components, use functional components with hooks.

Rules are applied globally to all inline and chat interactions.


Feature 6: Custom AI Models

Settings → Models shows the available models and lets you add others. Cursor supports any OpenAI-compatible endpoint — useful if you want to route inference through a self-hosted vLLM instance or an Ollama server:

  1. Add a new model
  2. Set the base URL to http://localhost:11434/v1 (for Ollama)
  3. Enter any placeholder API key (Ollama ignores it)
  4. Set the model name to whatever you have running (e.g., qwen3:8b)

This makes Cursor's chat and autocomplete call your local model instead of Anthropic or OpenAI APIs — useful for codebases where you can't send code externally.


Cursor vs GitHub Copilot

DimensionCursorGitHub Copilot
ArchitectureStandalone VS Code forkPlugin for VS Code, JetBrains, Neovim, etc.
Codebase indexingFull project index, semantic searchLimited; mainly active file context
Multi-file editsYes — chat can propose cross-file changesLimited; mostly single-file suggestions
Custom modelsYes — add any OpenAI-compatible endpointNo — Copilot models only
Custom rulesYes — global rules for AI behaviorLimited via Copilot instructions
Inline autocompleteMulti-line, edit-awareMulti-line, strong at next-line prediction
Editor flexibilityOnly VS CodeVS Code, JetBrains, Vim, Neovim, and others
PricingFree tier (limited); Pro $20/monthFree tier; Pro $10/month; Business $19/month

Choose Cursor if: You do most of your work in VS Code, want deep codebase context, and care about multi-file refactoring.

Choose Copilot if: You use multiple editors (JetBrains for Java, VS Code for scripts), work in a GitHub-heavy enterprise setup, or need the lowest friction onboarding.


Tips for Production Use

Keep sensitive code out of chat context: The @codebase and @git options send your code to Anthropic or OpenAI servers. For proprietary repositories, either route through your own model (local Ollama or a private vLLM deployment) or avoid using @codebase on sensitive files.

Use custom rules for consistency: If you're onboarding a new team member, Cursor's rules file acts as a lightweight coding standards enforcer. Document your patterns once and Cursor applies them automatically.

Combine Cmd+K and Cmd+L: Inline generation (Cmd+K) is faster for surgical edits. Chat (Cmd+L) is better for reasoning through an approach before writing any code. Use both.


Related Guides