LLM Copy Files
Overview
The "LLM Copy Files" extension for Visual Studio Code provides convenient ways to consolidate the contents of all currently open files or files within selected folders. You can either combine the contents into a single new file or copy them directly to the clipboard. This is particularly useful for quickly compiling code snippets, creating backups, or preparing code for sharing with others or large language models (LLMs).
Features
- Copy Opened Files: Copies the content of all open files in the editor and combines them into a single new file.
- Copy Opened Files to Clipboard: Copies the content of all open files directly to the clipboard.
- Get Files in Folder: Recursively retrieves and combines the content of all files within selected folders into a single new file.
- File Titles Included: Each file's content is preceded by its file name for easy identification.
- Language Syntax Highlighting: The language of each file is preserved in the copied content for proper syntax highlighting.
- Excludes Empty Files: Files with empty content are automatically excluded.
- Excludes Duplicate Files: Ensures each file is only copied once, even if opened multiple times.
- Relative File Paths: File paths are displayed relative to the workspace root for better readability.
- Multiple Folder Selection: Supports processing multiple folders.
- Progress Notification: Displays a notification during the processing of files.
Installation
From the Marketplace:
Manual Installation:
- Download the latest
.vsix
file from the releases page.
- Open VS Code, go to the Extensions view by clicking the Extensions icon in the Activity Bar.
- Click the
...
at the top-right corner of the Extensions view, select Install from VSIX...
, and choose the downloaded .vsix
file.
Usage
- Open all the files you want to copy in VS Code or select the desired folders in the Explorer view.
- Press
Ctrl+Shift+P
(or Cmd+Shift+P
on macOS) to open the Command Palette.
- Type
LLM Copy Files
and select one of the available commands:
- Copy Opened Files: Creates a new file containing the content of all open files, each prefixed with its respective file name and properly syntax highlighted.
- Copy Opened Files to Clipboard: Copies the content of all open files directly to the clipboard, formatted similarly to the "Copy Opened Files" command.
- Get Files in Folder: Right-click on one or more folders in the Explorer view and select "Get Files in Folder" to collect and combine the content of all files within the selected folders into a single new file.
Example
If you have the following files open in VS Code:
Running the "Copy Opened Files" command will create a new file with the following content:
# file1.js
\`\`\`javascript
console.log("This is file 1");
\`\`\`
# file2.js
\`\`\`javascript
console.log("This is file 2");
\`\`\`
Development
Prerequisites
Building the Extension
- Clone the repository:
git clone https://github.com/yourusername/llm-copy-files.git
cd llm-copy-files
- Install dependencies:
npm install
- Compile the TypeScript code:
npm run compile
- Launch the extension in VS Code:
- Open the project in VS Code.
- Press
F5
to open a new VS Code window with the extension loaded.
Publishing
- Ensure you have the
vsce
tool installed:
npm install -g vsce
- Package the extension:
vsce package
- Publish the extension:
vsce publish
Contributing
Contributions are welcome! Please open an issue or submit a pull request for any bugs, feature requests, or improvements.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgements
This extension was inspired by the need to quickly share code snippets with AI language models like ChatGPT. Special thanks to the developers of Visual Studio Code and the VS Code Extension API for making this possible.