URL Content Opener
This VS Code extension allows you to create multiple files in your workspace or open content in new editors using a custom vscode:// URI scheme.
Features
- Create multiple new files in your workspace by opening a vscode:// URI with content and filename parameters
- Open content in new unnamed editors when no filename is provided
- Handle multiple files in a single URI
Usage
To create new files or open content, use the following URI format:
vscode://anthropic.url-content-opener?content=<base64_encoded_content>&filename=example.txt&content=<base64_encoded_content>&filename=another.txt
- Use multiple
content
and filename
pairs to create or open multiple files.
- The
content
parameter should be base64-encoded to support various types of content, including newlines and special characters.
- The
filename
parameter is optional for each content. If provided, a new file will be created in your workspace. If omitted, the content will open in a new unnamed editor.
Example for creating two files and opening one unnamed editor:
vscode://anthropic.url-content-opener?content=RmlsZSAxIGNvbnRlbnQ=&filename=file1.txt&content=RmlsZSAyIGNvbnRlbnQ=&filename=file2.txt&content=VW5uYW1lZCBlZGl0b3IgY29udGVudA==
In this example:
RmlsZSAxIGNvbnRlbnQ=
is the base64 encoding of "File 1 content"
RmlsZSAyIGNvbnRlbnQ=
is the base64 encoding of "File 2 content"
VW5uYW1lZCBlZGl0b3IgY29udGVudA==
is the base64 encoding of "Unnamed editor content"
When you open this URI (e.g., by clicking a link or entering it in a browser), VS Code will:
- Open and activate the extension
- For each content/filename pair:
- Decode the base64-encoded content
- If a filename is provided:
- Create the file with the specified content in your workspace
- Open the newly created file in the editor
- If no filename is provided:
- Open the content in a new unnamed editor
Requirements
- Visual Studio Code version 1.92.0 or higher
Extension Settings
This extension does not add any VS Code settings.
Known Issues
- When creating files, the extension currently only supports creating files in the root of the first workspace folder.
Security Considerations
- The extension performs basic sanitization of file contents and validates filenames to prevent potential security issues.
- Always be cautious when opening URIs from untrusted sources.
Following extension guidelines
This extension follows the VS Code extension guidelines. For more information, see:
Enjoy!