Copy files or folder trees into your clipboard as Markdown. Ready to paste into AI, chats, docs, or code reviews.
This is a fork of the original Copy Context extension by Roland Chelwing, with additional features and improvements:
- Copy Selection: Copy selected text from the active editor with context information (file path and line numbers)
The original extension is licensed under the MIT License, and this fork maintains the same license.
-
Explorer
- Select one or more files or folders → right-click → Copy Content
- Select one or more files or folders → right-click → Copy Tree
-
Editor Tab
- Right-click a tab title → Copy Content (This Tab) or … (All Open Tabs).
-
Editor Selection
- Select text in an editor → right-click → Copy Selection as context
-
Paste anywhere and your Markdown snippet or tree is on the clipboard
- Explorer: grab paths + syntax-highlighted code blocks for selected files/folders
- Tabs: copy the active file or all open files at once (Unsaved buffers (Untitled) are skipped)
- Respects include/exclude globs, VS Code Explorer excludes & (opt-in)
.gitignore
Copy Content (Explorer)
Copy Content (Tabs)
- Copy selected text from the active editor with context information
- Includes file path and line numbers in the output
- Maintains syntax highlighting with proper language detection
- Respects the same size limits as other copy operations
Copy Selection as context output format:
// src/example.ts:10-15
```typescript
// src/example.ts:10-15
selected code here
- Generates a Markdown tree of your selected files/folders
- If you select specific files, only those file paths are included
- If you select folders, the full folder tree and contents are included
- Respects the same filters (globs, Explorer excludes,
.gitignore)
Copy Tree
-
Install dependencies:
npm install
-
Build the extension:
npm run build
-
Package the extension:
# Install vsce if not already installed npm install -g @vscode/vsce # Package the extension vsce package
-
Install the extension locally:
code --install-extension copy-code-context-9.9.9.vsix
- Download the
copy-code-context-9.9.9.vsixfile from the Releases page - Open VS Code
- Go to Extensions → Click the three dots → Install from VSIX...
- Select the downloaded VSIX file
| Setting | Default | Description |
|---|---|---|
copyContext.excludeGlobs |
[] |
Global exclude patterns applied to all commands. Command-specific excludes will be merged with these. |
copyContext.includeGlobs |
[] |
Global include patterns applied to all commands. Command-specific includes will be merged with these. |
copyContext.includeEmojis |
true |
Include emojis in the output (📁 for folders, 📄 for files). |
copyContext.maxContentSize |
500000 |
Max total size (bytes) of all file contents to copy. |
copyContext.respectVSCodeExplorerExclude |
true |
Skip files/folders hidden by your VS Code files.exclude settings. |
copyContext.respectGitIgnore |
false |
Skip files matching your project's .gitignore (opt-in). |
You can override filters for specific commands. These are merged with the global settings.
| Setting | Default | Description |
|---|---|---|
copyContext.copyContent.excludeGlobs |
[] |
Additional exclude patterns for Copy Content only. |
copyContext.copyContent.includeGlobs |
[] |
Additional include patterns for Copy Content only. |
copyContext.copyTree.excludeGlobs |
[] |
Additional exclude patterns for Copy Tree only. |
copyContext.copyTree.includeGlobs |
[] |
Additional include patterns for Copy Tree only. |
Example: Exclude test files globally, but include them when copying content:
{
"copyContext.excludeGlobs": ["**/*.test.ts"],
"copyContext.copyContent.includeGlobs": ["**/*.test.ts"]
}This extension is released under the MIT License.


