Copy Paste Image
A powerful VS Code extension for seamlessly pasting images into Markdown files with intelligent features including image deduplication, smart renaming, and automatic reference updates.

Features
🖼️ Smart Image Pasting
- Clipboard Integration: Automatically detects and saves images from clipboard (screenshots, copied image files)
- Original Filename Preservation: Maintains original filenames when copying image files
- Timestamp Generation: Auto-generates timestamp-based filenames for screenshots
- Format Support: Supports PNG, JPEG, GIF, BMP, WebP formats
🔄 Intelligent Image Deduplication
- Content Hash Detection: Uses MD5 algorithm to detect duplicate images
- Smart Scanning: Automatically scans attachment folders for existing images
- Direct Reference: References existing files instead of creating duplicates
- Storage Optimization: Reduces project size by avoiding duplicate image storage
🏷️ Smart Image Renaming
- Bulk Reference Updates: Automatically updates all Markdown references when renaming images
- Safe Renaming: Validates filenames and prevents conflicts
- Reference Preview: Shows all files that reference the image before renaming
- Confirmation Dialog: Displays complete file paths for user confirmation
- Intelligent Matching: Precise filename matching to avoid false replacements
📁 File Migration
- Batch Move/Copy: Move or copy linked files in Markdown documents with automatic link updates
- Reference Tracking: Automatically updates all Markdown references when files are moved
- Safe Operations: Validates file operations and prevents conflicts
- Workspace Integration: Seamlessly integrates with VS Code's file management
🔧 Intelligent Link Repair
- Broken Link Detection: Automatically scans and identifies invalid file links in Markdown documents
- Smart File Matching: Uses advanced algorithms to find potential replacement files based on filename similarity
- Multiple Suggestions: Provides ranked suggestions with confidence scores for each broken link
- Flexible Repair Options: Choose to fix, delete, or skip each broken link individually
- Relative Path Correction: Automatically calculates correct relative paths based on file locations
⚡ Seamless Integration
- Markdown Focus: Works seamlessly in Markdown files
- Fallback Behavior: Executes default paste in non-Markdown files
- Context Menu: Right-click rename functionality in Explorer
- Keyboard Shortcuts: Standard Ctrl+V/Cmd+V integration
Installation
- Open VS Code
- Go to Extensions (Ctrl+Shift+X)
- Search for "Copy Paste Image"
- Click Install
- Reload VS Code
Usage
Basic Image Pasting
- Copy an image to clipboard (screenshot, copy image file, etc.)
- Open a Markdown file in VS Code
- Press
Ctrl+V (Windows/Linux) or Cmd+V (macOS)
- The image will be automatically saved and a Markdown link inserted
Image Renaming with Reference Updates
- Right-click on an image file in the Explorer
- Select "重命名图片并更新引用" (Rename Image and Update References)
- Enter the new filename
- Confirm the operation
- All Markdown references will be automatically updated
File Migration
- Open a Markdown file containing links to local files
- Right-click in the editor and select "迁移当前文件的链接文件" (Migrate Linked Files)
- Choose operation type:
- Move: Move files to target directory
- Copy: Copy files to target directory
- Set target directory (defaults to
assets folder in project root)
- Review reference warnings if files are used by other Markdown files
- Confirm the operation
- All file links in the current document will be automatically updated
Intelligent Link Repair
- Open a Markdown file that may contain broken links
- Right-click in the editor and select "智能修复文件链接" (Fix Broken Links)
- The extension will scan all links in the document and identify broken ones
- For each broken link, you'll see:
- Suggestions: Ranked list of potential replacement files with confidence scores
- Options: Fix with suggested file, delete the link, or skip
- Choose the appropriate action for each broken link
- All selected fixes will be applied automatically with correct relative paths
File Conflict Handling
When pasting an image with an existing filename, you'll get these options:
- Overwrite: Replace the existing file
- Rename: Save with a new filename
- Reference Only: Insert link to existing file without saving
- Cancel: Cancel the operation
Configuration
Configure the extension in VS Code settings:
{
"copyPasteImage.path": "images",
"copyPasteImage.prefix": "image",
"copyPasteImage.suffix": "${YY}${MM}${DD}${HH}${mm}${ss}",
"copyPasteImage.searchPath": ""
}
Settings Description
| Setting |
Description |
Default |
copyPasteImage.path |
Relative path for saving images (relative to workspace root) |
"images" |
copyPasteImage.prefix |
Prefix for image filenames |
"image" |
copyPasteImage.suffix |
Suffix for image filenames with time variables |
"${YY}${MM}${DD}${HH}${mm}${ss}" |
copyPasteImage.searchPath |
Directory path for finding image references (empty = entire workspace) |
"" |
Time Variables
${YY}: Year (2-digit)
${MM}: Month (2-digit)
${DD}: Day (2-digit)
${HH}: Hour (2-digit)
${mm}: Minute (2-digit)
${ss}: Second (2-digit)
- ✅ Windows
- ✅ macOS
- ✅ Linux
Requirements
- VS Code 1.74.0 or higher
- Node.js (for development)
Known Issues
- Large images may take a moment to process
- Some clipboard formats may not be supported on all platforms
Release Notes
1.2.1
- FIXED: 修复了当Markdown文件位于子文件夹时相对路径计算错误的问题
- FIXED: 解决了生成过多
../前缀导致路径错误的问题
- CONFIRMED: 智能修复链接和文件迁移功能已可通过命令面板(Cmd+Shift+P)访问
1.2.0
- NEW: Intelligent link repair functionality
- NEW: Automatic detection and fixing of broken file links
- NEW: Smart file matching with confidence scoring
- IMPROVED: Fixed relative path calculation for Markdown files in subdirectories
- IMPROVED: Enhanced path handling for cross-platform compatibility
- FIXED: Resolved package-lock.json formatting issues
1.1.0
- Added file migration feature for Markdown documents
- Batch move/copy linked files with automatic link updates
- Reference checking to prevent broken links
- Enhanced user interface with operation selection dialog
1.0.0
- Initial release
- Smart image pasting with automatic saving
- Intelligent deduplication
- Smart renaming with reference updates
- Seamless VS Code integration
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
Development
# Clone the repository
git clone https://github.com/your-username/vscode-copy-paste-image.git
# Install dependencies
npm install
# Compile TypeScript
npm run compile
# Watch for changes
npm run watch
# Package the extension
npm run package
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
If you encounter any issues or have feature requests, please create an issue on GitHub.
Enjoy seamless image management in your Markdown files! 🎉