Workspace Management

45 min intermediate Lesson 8

Learning Outcomes

  • Organise large projects using Cursor's workspace features for AI-friendly navigation
  • Use multiple cursors combined with AI assistance for bulk edits
  • Perform intelligent search and replace operations using AI understanding
  • Manage multiple open files effectively with AI context in mind
  • Apply bulk operations across files while maintaining project coherence

Lesson Plan

Segment Duration Topic
Intro 4 min Why workspace organisation matters for AI-assisted coding
Demo 1 8 min Project organisation strategies for large codebases
Demo 2 8 min Multiple cursors with AI — bulk editing patterns
Demo 3 8 min AI-aware search and replace
Explain 5 min Managing context — what the AI sees from open files
Demo 4 7 min Multi-file editing workflows
Wrap-up 5 min Best practices and key takeaways

Before You Begin

Pre-work:

  • Complete Lesson 7 — Agent Mode
  • Have a project with at least 15-20 files open in Cursor
  • Familiarise yourself with VS Code's multi-cursor feature (Alt+Click to add cursors)
  • Know the basics of Find and Replace (Cmd+H / Ctrl+H)

Shopping List:

  • A medium-to-large project open in Cursor (a real project you work on is ideal)
  • Multiple files with similar patterns that could benefit from bulk edits
  • The Explorer panel visible (Cmd+Shift+E / Ctrl+Shift+E)

1 Organising Large Projects in Cursor

A well-organised project makes AI assistance significantly more effective. When files are logically grouped and well-named, the AI can find relevant context faster and make better suggestions.

Project structure principles for AI-friendly codebases:

src/
├── features/           # Group by feature/domain
│   ├── auth/
│   │   ├── components/
│   │   ├── hooks/
│   │   ├── services/
│   │   └── types.ts
│   ├── users/
│   └── posts/
├── components/         # Shared/common components
│   ├── ui/            # Primitives (Button, Input, Modal)
│   └── layout/        # Layout components (Header, Sidebar)
├── lib/               # Utilities and helpers
├── hooks/             # Shared hooks
└── types/             # Global type definitions

Why this matters for AI:

  • When you reference @src/features/auth/, the AI gets a focused, relevant context
  • Co-located files (component + hook + test) mean the AI can understand a feature holistically
  • Consistent naming lets the AI predict where things live

Using workspace folders effectively:

  • Collapse irrelevant folders in the Explorer to reduce visual clutter
  • Pin frequently used files by right-clicking a tab > "Pin Tab" (Cmd+K then Cmd+Enter)
  • Use Split Editor (Cmd+) to view related files side by side
  • Go to File with Cmd+P — type partial filenames to navigate quickly
  • Collapse irrelevant folders in the Explorer to reduce visual clutter
  • Pin frequently used files by right-clicking a tab > "Pin Tab" (Ctrl+K then Ctrl+Enter)
  • Use Split Editor (Ctrl+) to view related files side by side
  • Go to File with Ctrl+P — type partial filenames to navigate quickly

Workspaces for monorepos:

If you work in a monorepo, consider using VS Code Workspaces:

  1. File > Add Folder to Workspace
  2. Add only the folders you're actively working in
  3. This limits what the AI indexes and improves relevance

.cursorignore for AI indexing:

Create a .cursorignore file (similar to .gitignore) to exclude directories from AI indexing:

# .cursorignore
node_modules/
dist/
build/
.next/
coverage/
*.generated.ts
vendor/

This prevents the AI from wasting context on generated files, dependencies, or build artefacts.

TIP
Tip
Cursor indexes your project for AI features. Large projects with many irrelevant files (generated code, vendor libraries) can slow indexing and dilute AI context. Use .cursorignore aggressively for anything the AI shouldn't learn from.
NOTE
How It Works
Cursor builds an index of your codebase for semantic search and context retrieval. When you reference files with @ or the AI searches for context, it uses this index. A well-structured project with good .cursorignore means the AI finds relevant code faster.

2 Multiple Cursors with AI Assistance

Cursor inherits VS Code's powerful multi-cursor editing and enhances it with AI capabilities. Combining these features enables rapid bulk edits.

Basic multi-cursor shortcuts:

Action Shortcut
Add cursor at click position Option+Click
Add cursor above/below Cmd+Option+Up/Down
Select next occurrence of word Cmd+D
Select all occurrences of word Cmd+Shift+L
Add cursors to line ends of selection Option+Shift+I
Undo last cursor/selection Cmd+U
Action Shortcut
Add cursor at click position Alt+Click
Add cursor above/below Ctrl+Alt+Up/Down
Select next occurrence of word Ctrl+D
Select all occurrences of word Ctrl+Shift+L
Add cursors to line ends of selection Alt+Shift+I
Undo last cursor/selection Ctrl+U

Multi-cursor + AI workflow:

The power comes from selecting multiple locations and then applying AI edits across all of them simultaneously.

Example 1: Adding TypeScript types to multiple functions

  1. You have 10 functions that lack return types
  2. Use Cmd+D / Ctrl+D to select each function name (or use Find to locate them)
  3. Select all the relevant lines
  4. Press Cmd+K / Ctrl+K and say: "Add proper TypeScript return types to all these functions"
  5. Cursor applies types to each function based on its implementation

Example 2: Converting console.log to a logger

  1. Use Cmd+Shift+L / Ctrl+Shift+L to select all occurrences of console.log
  2. Instead of simple find-replace, press Cmd+K / Ctrl+K
  3. Say: "Replace each console.log with the appropriate logger level — logger.info for success messages, logger.error for errors, logger.debug for debug output"
  4. The AI understands the context of each console.log and chooses the right level

Example 3: Adding error handling to multiple API calls

  1. Select a block of code containing multiple fetch/axios calls
  2. Press Cmd+K / Ctrl+K
  3. Say: "Wrap each API call in try/catch with proper error handling that shows a toast notification"
  4. The AI wraps each call individually, preserving the specific error context
TIP
Tip
Cmd+D / Ctrl+D is incremental — each press selects the next occurrence. This lets you skip occurrences by pressing Cmd+K Cmd+D (skip current, move to next) for cases where you don't want ALL instances changed.
WARNING
Watch Out
When using multi-cursor with AI edits (Cmd+K), be careful with very large selections. If you select 200 lines with 15 edit points, the AI may struggle to produce a coherent edit. Keep multi-cursor AI edits focused: 5-10 points at a time.

3 AI-Enhanced Search and Replace

Standard find-and-replace is powerful but literal. Cursor's AI adds semantic understanding — it can replace patterns based on meaning, not just text matching.

Standard Find and Replace (still useful):

  • Find in file: Cmd+F
  • Replace in file: Cmd+H (with regex: click .* button)
  • Find in all files: Cmd+Shift+F
  • Replace in all files: Cmd+Shift+H
  • Find in file: Ctrl+F
  • Replace in file: Ctrl+H (with regex: click .* button)
  • Find in all files: Ctrl+Shift+F
  • Replace in all files: Ctrl+Shift+H

When standard replace works:

  • Renaming a variable that's always spelled the same way
  • Changing an import path across all files
  • Updating a version number in configuration files

When you need AI-enhanced replace:

Standard replace fails when:

  • The change is contextual (same text, different treatment based on context)
  • The replacement isn't a direct text swap (restructuring code)
  • You need to preserve meaning while changing form

AI-enhanced search and replace workflow:

  1. Use global search (Cmd+Shift+F / Ctrl+Shift+F) to find all instances
  2. Open each file from the search results
  3. Select the relevant code in each file
  4. Use Chat or Cmd+K to describe the semantic replacement

Example: Converting class components to functional components

Standard replace cannot do this — it requires understanding component structure.

  1. Search for extends React.Component across the project
  2. Open each result
  3. Select the entire class component
  4. Cmd+K: "Convert this class component to a functional component with hooks. Preserve all behaviour."
  5. The AI restructures lifecycle methods into useEffect, state into useState, etc.

Example: Updating API response handling

Your API changed from { data: [...] } to { results: [...], pagination: {...} }.

  1. Search for .data in API response handling code
  2. For each usage, select the surrounding context
  3. Cmd+K: "Update this to use the new API format where 'data' is now 'results' and pagination metadata is available at response.pagination"
  4. The AI updates each usage appropriately, including updating TypeScript types

Scoped search for targeted changes:

Use search filters to limit scope:

  • files to include: src/features/users/** — only search in user features
  • files to exclude: *.test.ts, *.spec.ts — skip test files
  • Use glob patterns: **/*.tsx — only TypeScript React files
NOTE
How It Works
Cursor's AI search uses both literal text matching (the search box) and semantic understanding (when you ask the AI about results). The combo is powerful: use literal search to find locations, then AI to understand and transform them.
TIP
Tip
For large-scale semantic replacements (20+ files), consider using Agent mode instead. Give the agent a task: 'Update all API response handlers to use the new pagination format. The change: response.data becomes response.results, and add pagination handling where appropriate.'

4 Managing Context — What the AI Sees

Understanding what the AI can "see" at any given moment helps you work more effectively. Context management is a key skill for AI-assisted development.

What contributes to AI context in Cursor:

Context Source When It's Included Your Control
Current file Always (for inline edits) Keep files focused and short
Selected text When you select before Cmd+K/L Select exactly what's relevant
@-mentioned files When you explicitly reference Choose the most relevant files
.cursor/rules Always Keep it concise
Open tabs May be included as background context Close irrelevant tabs
Codebase index When AI searches for context Configure .cursorignore

Managing open files for optimal AI context:

Strategy 1: The "working set" approach

Keep only the files relevant to your current task open:

  • Close files from previous tasks
  • Open the 3-5 files directly related to what you're working on
  • Pin files you reference constantly (types, utilities)

Strategy 2: Tab groups for different contexts

Use VS Code's tab groups to organise by concern:

  • Group 1: Feature files you're building
  • Group 2: Reference files (types, interfaces, examples)
  • Group 3: Test files

Strategy 3: Split editor for reference

  • Cmd+\ to split editor right
  • Cmd+K then Cmd+\ to split editor down
  • Keep reference files (types, interfaces) in one pane and working files in another
  • Use Cmd+1, Cmd+2 to switch between editor groups
  • Ctrl+\ to split editor right
  • Ctrl+K then Ctrl+\ to split editor down
  • Keep reference files (types, interfaces) in one pane and working files in another
  • Use Ctrl+1, Ctrl+2 to switch between editor groups

Explicit context with @-mentions:

When the AI's automatic context isn't enough, be explicit:

@src/types/user.ts @src/services/userService.ts

Create a new hook that fetches user data with proper typing and error handling,
following the pattern in @src/hooks/useProductData.ts

This tells the AI exactly which files to consider, instead of hoping it finds the right context.

Context window limits:

The AI has a finite context window. If you include too many files, earlier context may be "pushed out":

  • A Chat conversation with many back-and-forth messages loses early context
  • References to 10+ large files may hit limits
  • Keep conversations focused; start a new chat when switching topics
WARNING
Watch Out
Having 50 tabs open doesn't help the AI — it may actually hurt by diluting context. Close files you're not actively referencing. The AI works better with 5 highly relevant files than 50 marginally relevant ones.
TIP
Tip
Use Cmd+W / Ctrl+W to close the current tab, or right-click a tab and select 'Close Others' to quickly reduce your open file count. The keyboard shortcut Cmd+K Cmd+W / Ctrl+K Ctrl+W closes all tabs at once.

5 Bulk Operations Across Files

When you need to make similar changes across many files, Cursor offers several approaches ranging from manual multi-file editing to AI-automated bulk operations.

Approach 1: Agent mode for bulk changes

Best for: Semantic changes that require understanding (not simple text replacement).

Agent task: "Add JSDoc documentation to all exported functions in src/lib/.
Each function should have a @param tag for each parameter and a @returns tag.
Infer the descriptions from the function names and implementations."

The agent will read each file, understand the functions, and add appropriate documentation.

Approach 2: Multi-file inline edits

Best for: Similar but not identical changes across a few files (3-7 files).

  1. Open all the files that need changes
  2. In each file, select the relevant section
  3. Use Cmd+K / Ctrl+K with the same instruction
  4. The AI applies the instruction with file-specific context

Approach 3: Find across files + batch Cmd+K

Best for: Changes at consistent locations (e.g., all files have a similar structure).

  1. Cmd+Shift+F / Ctrl+Shift+F to find the pattern across files
  2. Click through results, opening each file
  3. In each file, select and apply the same Cmd+K instruction
  4. Accept or modify each result

Approach 4: Terminal scripts + AI generation

Best for: Mechanical, repetitive changes that follow a strict pattern.

Ask Chat: "Write a bash script that adds a copyright header to all .ts files in src/ that don't already have one."

Then run the generated script in the terminal.

Real-world bulk operation examples:

Example 1: Adding error boundaries to all page components

Agent: "For every file in src/app/ that exports a default page component,
create a corresponding error.tsx file that shows a user-friendly error
message with a retry button. Follow the pattern in src/app/dashboard/error.tsx."

Example 2: Migrating CSS-in-JS to Tailwind

This is too complex for a single agent task. Break it down:

  1. Agent task 1: "Convert styled-components in src/components/ui/ to Tailwind classes. Start with Button.tsx, Input.tsx, and Card.tsx."
  2. Agent task 2: "Continue the Tailwind migration for Modal.tsx, Dropdown.tsx, and Tabs.tsx."
  3. After each batch, review and test before continuing.

Example 3: Adding loading states to all data-fetching components

Agent: "For each component in src/features/ that uses useQuery hooks,
add a loading skeleton state. Use the LoadingSkeleton component from
src/components/ui/LoadingSkeleton.tsx. Show the skeleton when isLoading
is true. Reference src/features/users/UserList.tsx for the pattern."
TIP
Tip
For bulk operations, commit between batches. If you're changing 20 files, commit after every 5-7 file changes. This gives you safe rollback points and makes code review easier.
WARNING
Watch Out
Bulk AI edits can introduce subtle inconsistencies. After a bulk operation, run your full test suite and linter. Also do a quick visual scan of the git diff — look for files where the AI did something slightly different from the others.

6 Productivity Workflows for Large Projects

Combine workspace management techniques into complete workflows for day-to-day development in large codebases.

Workflow: Starting a new feature

  1. Prepare workspace:

    • Close all unrelated tabs (Cmd+K Cmd+W / Ctrl+K Ctrl+W)
    • Open the directory where your feature will live
    • Open 2-3 reference files (existing features with similar patterns)
    • Pin your types/interfaces file
  2. Scaffold with Agent:

    • Use Agent mode to create the initial file structure
    • Reference the existing feature as a pattern
  3. Iterate with Chat + Inline:

    • Use Chat for design decisions
    • Use Cmd+K for rapid edits within the generated files
  4. Review and cleanup:

    • Close reference files
    • Open all new files and review
    • Use multi-cursor for any consistent tweaks

Workflow: Investigating a bug in unfamiliar code

  1. Find the entry point:

    • Cmd+Shift+F / Ctrl+Shift+F to search for the error message or symptom
    • Open the relevant file
  2. Build context progressively:

    • Open the file where the bug manifests
    • Use "Go to Definition" (F12) to trace the call chain
    • Open each file in the chain (usually 3-5 files)
    • Keep these open as your working context
  3. Ask AI with full context:

    • Reference all relevant files with @-mentions
    • Describe the symptom and ask for diagnosis
    • The AI can now see the full chain of execution

Workflow: Code review with workspace setup

  1. Checkout the PR branch
  2. View changed files: Use git diff --name-only main in terminal
  3. Open all changed files as your working set
  4. Use Chat: "Review these changes for potential issues. I have the changed files open: @file1.tsx @file2.tsx @file3.tsx"
  5. Navigate between issues using the AI's suggestions

Keyboard shortcuts for efficient navigation:

Action Shortcut
Go to file by name Cmd+P
Go to symbol in workspace Cmd+T
Go to definition F12
Peek definition (inline) Option+F12
Go back Ctrl+-
Go forward Ctrl+Shift+-
Switch between open files Ctrl+Tab
Close current tab Cmd+W
Action Shortcut
Go to file by name Ctrl+P
Go to symbol in workspace Ctrl+T
Go to definition F12
Peek definition (inline) Alt+F12
Go back Alt+Left
Go forward Alt+Right
Switch between open files Ctrl+Tab
Close current tab Ctrl+W
NOTE
How It Works
Efficient workspace management is about reducing friction between intention and action. Every second spent searching for a file or re-establishing context is a second not spent building. These shortcuts and workflows compound — saving 5 seconds per navigation adds up to hours over a week.
TIP
Tip
Create a workspace file (.code-workspace) for your most common project configurations. This saves your folder arrangement, settings overrides, and recommended extensions — so you can switch between project contexts instantly.

Questions & Answers

Q: Does having many tabs open slow down Cursor's AI features?
Having many tabs open does not directly slow down AI responses, but it can dilute context quality. Cursor may use open files as background context, so 50 open tabs means the AI might consider irrelevant files. Close tabs you're not actively using. Performance impact is minimal, but context relevance improves with a focused working set.
Q: Can I use .cursorignore and .gitignore together?
Yes, and they serve different purposes. .gitignore tells Git which files to not track. .cursorignore tells Cursor's AI which files to not index. You might want to gitignore node_modules (standard) AND cursorignore generated files that ARE tracked by git but aren't useful for AI context (like compiled CSS, auto-generated API clients, or migration files).
Q: How do I handle a project with thousands of files — does Cursor index everything?
Cursor indexes what it can within its limits. For very large projects (10,000+ files), use .cursorignore to exclude non-essential directories (vendor, generated, build output). Focus the index on your source code — the part where AI assistance is most valuable. You can also use workspace folders to include only the subsections of a monorepo you're actively working in.
Q: Is there a way to save and restore my workspace layout (which files are open, split editors)?
Yes. Create a .code-workspace file (File > Save Workspace As...). This saves your folder configuration and settings. For tab layouts specifically, VS Code/Cursor also remembers your last session's open tabs when you reopen the project. For more control, extensions like "Workspace Manager" or "Project Manager" let you save and switch between named workspace configurations.

Key Takeaways

  1. Structure your project for AI — logical grouping and clear naming help the AI find relevant context
  2. Use .cursorignore to exclude generated files, dependencies, and build output from AI indexing
  3. Multi-cursor + AI enables semantic bulk edits that simple find-replace cannot achieve
  4. Manage your open tabs — 5 relevant files beats 50 random ones for AI context quality
  5. Break bulk operations into batches — commit between batches for safe rollback points
  6. Learn navigation shortcuts — speed between files compounds into significant productivity gains

Next Steps: In Lesson 9 — Extensions & Integrations, you'll learn how to extend Cursor's capabilities with VS Code extensions, Git integration, and external tool connections.