How to Edit Multiple Files Simultaneously with GitHub Copilot Edits
GitHub Copilot Edits is a workspace editing feature that lets you add multiple files to a working set and issue natural language commands to modify them concurrently. This guide covers how to set up your files, prompt the model, and review the proposed diffs, while organizing your workspace files in collaborative teams.
Why Edit Multiple Files with GitHub Copilot Edits
Most developer tools default to single-file isolated contexts, forcing engineers to manually copy, paste, and stitch modifications across their codebase when refactoring. Copilot Edits addresses this coordination barrier by letting you build a dynamic working set of files and prompt changes across them simultaneously.
Conventional coding assistants operate file by file. A developer might prompt the assistant inside a single module, copy the output, and paste it into the editor. If that modification changes a shared type signature or exports a new utility method, the developer must open every calling file individually, locate the lines of code, and run a separate prompting session to update them. This serial process introduces syntax discrepancies, broken imports, and compiler errors. The overhead of coordinating multi-file refactoring manually often offsets the speed gains of using AI-assisted autocomplete.
By grouping files into a single context, Copilot Edits eliminates the need to jump between editors. It allows you to issue a single natural language instruction that is processed across all active files. When the assistant changes a database schema, it simultaneously updates the data access logic, the routing controller, and the unit tests. A study conducted by GitHub on developer productivity showed that developers using GitHub Copilot completed tasks 55% faster on average than those who did not. The modifications are generated as a unified proposal, preserving consistency and resolving dependency relationships in a single pass. By connecting coding assistants to Fastio workspaces, teams can ensure that AI-generated modifications are synchronized.
How to Launch Copilot Edits and Build a Working Set
To begin a multi-file editing session in Visual Studio Code, you must open the dedicated Copilot Edits panel. You can trigger this interface by selecting the Open Copilot Edits command from the Command Palette, or by running the keyboard shortcut mapped to the editor edit session command. This action opens a separate chat thread in the sidebar, which is optimized for code modification rather than general conversational queries.
Once the editing panel is open, you define the workspace scope by constructing a working set. The working set is the explicit collection of files that the assistant is authorized to analyze and modify. When refactoring code with external tools, you can configure them to work with your shared workspace to ensure team access. You can build this set using three primary methods:
- Editor Tabs: Visual Studio Code automatically populates the working set with your open editor tabs, letting you transition from active coding to automated editing.
- Drag and Drop: You can drag files or entire directories from the File Explorer sidebar and drop them directly into the Copilot Edits chat window to include them.
- Inline Reference: You can type the
#symbol in the prompt input field to search for specific files, folders, or symbols in your workspace and add them to the session.
If you are working in a Git-tracked directory, the editor also suggests related files based on your commit history. If you add a controller file, the interface may suggest adding the corresponding test file because they are frequently modified together. To add files to the working set from the active editor window, you can use the Cmd+I keyboard shortcut on macOS or Ctrl+I on Windows. Keeping your working set focused is important. Removing irrelevant files prevents the session context from becoming cluttered, reducing token consumption and improving the accuracy of the proposed modifications.
Adding Files via Prompting and Shortcuts
The prompt-based file inclusion workflow is useful for adding files dynamically. By typing the # character in the chat input, you can query your workspace index. You can search by filename, class name, or method name. This lets you pinpoint specific targets without leaving your keyboard or using the mouse.
Managing the size of the working set is a key factor in obtaining high-quality code changes. If you add too many files or select large directories, the AI assistant receives too much noise. Select only the core files that define the interface and the implementation. For example, if you are updating an API endpoint, include only the endpoint handler, the data access file, and the test file. Do not include your entire source directory.
How to Refactor Codebases with Multi-File Prompts
With your working set defined, you can issue natural language prompts to perform complex refactoring tasks across your files. When writing these instructions, describe the desired outcome clearly, name the target functions, and specify the handling of edge cases.
Consider a practical example where you need to refactor a user login mechanism in a Node.js web service. The task involves modifying the authentication helper, the controller that handles login requests, and the test suite.
The original files are structured as follows:
The authentication helper file: src/utils/auth.js
// src/utils/auth.js
export function generateToken(user) {
return `session-token-${user.id}`;
}
The route handler file: src/routes/login.js
// src/routes/login.js
import { generateToken } from '../utils/auth.js';
export function loginHandler(req, res) {
const { user } = req;
if (!user) {
return res.status(401).send('Unauthorized');
}
const token = generateToken(user);
res.status(200).send({ token });
}
The unit test file: tests/login.test.js
// tests/login.test.js
import { loginHandler } from '../src/routes/login.js';
test('loginHandler returns token', () => {
const req = { user: { id: 42 } };
const res = {
status: (code) => ({
send: (data) => {
if (code !== 200 || !data.token) {
throw new Error('Test failed');
}
}
})
};
loginHandler(req, res);
});
To update this logic, you add all three files to your working set and write the following prompt in the Copilot Edits panel:
Refactor the token generation helper to return a structured object containing the session token, the token expiration timestamp, and user role metadata instead of a raw string. Update the route handler and tests to process this new object format.
Copilot Edits analyzes the files in the working set and proposes concurrent changes.
The updated auth utility: src/utils/auth.js
// src/utils/auth.js
export function generateToken(user) {
return {
token: `session-token-${user.id}`,
expiresAt: Date.now() + 3600000,
role: user.role || 'user'
};
}
The updated route handler: src/routes/login.js
// src/routes/login.js
import { generateToken } from '../utils/auth.js';
export function loginHandler(req, res) {
const { user } = req;
if (!user) {
return res.status(401).send('Unauthorized');
}
const session = generateToken(user);
res.status(200).send({
token: session.token,
expiresAt: session.expiresAt,
role: session.role
});
}
The updated test suite: tests/login.test.js
// tests/login.test.js
import { loginHandler } from '../src/routes/login.js';
test('loginHandler returns token', () => {
const req = { user: { id: 42, role: 'admin' } };
const res = {
status: (code) => ({
send: (data) => {
if (code !== 200 || !data.token || !data.expiresAt || data.role !== 'admin') {
throw new Error('Test failed');
}
}
})
};
loginHandler(req, res);
});
The assistant applies the changes across the utility, the handler, and the test suite simultaneously, ensuring that the new token object structure is handled correctly by all dependent files.
Best Practices for Multi-File Prompts
Prompts should be incremental. Instead of asking the tool to rewrite the entire application in one turn, break the refactoring into smaller, logical steps. For instance, first update the core data models, then update the controllers, and finally update the test assertions. This structured path minimizes errors and allows you to test code changes at each stage.
If the compiler returns errors after the changes are generated, you can feed these errors back into the chat. If the compiler indicates that a function argument is undefined, copy the error message and paste it into the prompt box. The assistant will update the files in your working set to resolve the issue, helping you iterate towards a clean build.
How to Review and Commit Multi-File Proposed Edits
Proposed edits do not overwrite your files immediately. The editor holds the changes in an unsaved state, allowing you to review the modifications before committing them to your workspace.
To review these proposals, Visual Studio Code uses standard side-by-side diff views. You can click on each file in the working set list to open the diff comparison, showing exactly what lines will be added or removed. The Copilot Edits UI provides options to manage the proposed modifications:
- Keep: Accepts the proposed edits for the selected file or for all modified files in the working set, saving the changes to disk.
- Undo: Discards the proposed edits, reverting the files to their pre-prompt state.
- Iterative Chat: If the changes are close to your goal but require adjustment, you can type a follow-up prompt in the chat. For example, you can write "Change the token expiration time to two hours instead of one" to modify the proposed code in the active session.
Checking the diffs line by line is a critical quality control step. AI assistants can introduce subtle logical bugs or make unintended formatting changes. Reviewing the edits ensures that the refactored code meets your project's standards and integrates correctly with the rest of your system.
Resolving Conflicts and Staging Changes
If you modify a file locally while the assistant is writing code, a conflict can occur. VS Code handles this by highlighting the conflicting regions and prompting you to choose between your manual edits and the assistant's proposal. To avoid conflicts, let the assistant complete its generation before typing in the editor.
Once you click Keep to accept the changes, use your version control tool to review the final output. Staging the changes using Git allows you to inspect the modifications in your source control window, run unit tests, and verify that the application compiles correctly before staging and committing.
Coordinate coding agents in one shared workspace
Connect GitHub Copilot and custom agents to version-controlled Fastio workspaces via the remote Model Context Protocol server. Start your 14-day free trial today.
How to Persist Workspace Assets Across Distributed Teams
When refactoring code with multi-file edit tools, developers generate configurations, documentation, and schema files that must be shared across the wider engineering team. Storing and coordinating these assets requires a persistent file management system.
For simple version control, developers often rely on local directories or standard git repositories. However, local files are inaccessible to non-developer teammates, and pushing raw code to central code hosting platforms does not solve the challenge of organizing and searching surrounding project documentation. Standard cloud folders (such as Google Drive or Microsoft OneDrive) or object storage services (like Amazon S3) provide shared access, but they lack developer-centric tools, do not index code semantics natively, and can trigger API rate limits under high-frequency writes from automated scripts.
A persistent Fastio workspace provides an alternative coordination layer. By establishing a shared workspace, humans and external agents collaborate on the same file system, leveraging capabilities built for code and document management:
- Per-File Version History: Fastio tracks all file updates. If an agent or teammate uploads a modified utility configuration, the platform preserves the complete file history, allowing you to inspect changes and restore prior versions at any time.
- Remote MCP Server Access: You can connect other AI agents to your shared workspace. Fastio hosts a remote Model Context Protocol endpoint (which you can manage via Fastio's agent-specific storage solution) over Streamable HTTP and SSE transport, giving tools the ability to read, write, and query files programmatically.
- Intelligence Mode: Enabling workspace intelligence indexes all uploaded assets automatically. Developers and non-technical stakeholders can search files by meaning, retrieve content, and run citation-backed chat sessions using Ripley AI.
- Ownership Transfer: If a developer builds a prototype workspace or structured directory for a client, they can transfer the organization and workspaces via a claim link when handoff is complete.
Every organization starts with a 14-day free trial, which requires a credit card. Plans are Starter at 29 dollars per month, Business at 99 dollars per month, and Growth at 299 dollars per month. Creating an account is free; doing real work requires an organization on a paid subscription. Using capabilities built for code and document management creates a unified environment that ensures team coordination remains secure and auditable. You can activate your trial on the Fastio pricing page.
Frequently Asked Questions
How do I edit multiple files with GitHub Copilot?
You can edit multiple files simultaneously by opening Copilot Edits in Visual Studio Code, adding target files to your working set, and entering a prompt describing the changes. Copilot will generate proposed edits across all selected files concurrently, which you can review and accept.
What is the working set in Copilot Edits?
The working set is the explicit list of files that GitHub Copilot is authorized to read and modify during an edit session. You can add files to the working set using keyboard shortcuts, drag-and-drop, or by typing the `#` symbol in the prompt input.
Can Copilot refactor multiple files at once?
Yes. By using the dedicated Copilot Edits pane and defining a working set, Copilot can analyze dependencies across multiple modules and apply refactoring changes simultaneously, ensuring that call signatures, imports, and tests remain aligned.
Related Resources
Coordinate coding agents in one shared workspace
Connect GitHub Copilot and custom agents to version-controlled Fastio workspaces via the remote Model Context Protocol server. Start your 14-day free trial today.