Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Copy File Content is a plugin for IntelliJ IDEs that allow you to quickly copy the contents of selected files and directories to the clipboard, formatted according to customizable settings.

Notifications You must be signed in to change notification settings

mwguerra/copy-file-content

Repository files navigation

Copy File Content Plugin Icon Copy File Content Plugin

Description

Copy File Content is a plugin that enhances your workflow by allowing you to quickly copy the contents of selected files and directories to the clipboard, formatted according to customizable settings.

Perfect for:

  • πŸ“ Sharing code snippets via chat or email
  • πŸ€– Building context for LLM apps (ChatGPT, Claude, Gemini, etc.)
  • πŸ“‹ Code reviews and documentation
  • πŸ”„ Quickly gathering code from multiple files

✨ Features

Core Features

  • πŸ“ Copy from Project Tree: Right-click files or directories in the project explorer to copy their content
  • πŸ“‘ Copy All Open Tabs: Copy content from all currently open editor tabs at once
  • πŸ”„ VCS Integration: Copy files directly from the Git Changes/Commit window and VCS Log
  • πŸ’Ύ In-Memory Reading: Automatically captures unsaved changes from open files
  • πŸ“Š Statistics: Shows file count, lines, words, and estimated tokens after copying
  • 🎨 Customizable Formatting: Configure headers, pre/post text, and line spacing
  • 🎯 Smart Filtering: Filter by file extension and set maximum file count limits
  • ⚑ Performance Options: Choose between strict memory reading or cached reading for better performance

πŸ“₯ Installation

Install from JetBrains Marketplace

  1. Open IntelliJ IDEA
  2. Go to Settings/Preferences > Plugins > Marketplace
  3. Search for "Copy File Content"
  4. Click Install

Install Manually

  1. Download the latest release
  2. Go to Settings/Preferences > Plugins > βš™οΈ > Install plugin from disk...
  3. Select the downloaded ZIP file

πŸš€ Usage

Method 1: Copy from Project Tree

  1. Select one or more files/directories in the Project explorer
  2. Right-click on the selection
  3. Choose "Copy File Content to Clipboard"
  4. Content is now in your clipboard with formatted headers!

Method 2: Copy All Open Tabs

  1. Open multiple files in editor tabs
  2. Right-click on any tab
  3. Choose "Copy All Open Tabs Content to Clipboard"

Method 3: Copy from VCS Changes Window

  1. Enable VCS (Git, SVN, etc.)
  2. Make changes to files
  3. Open the Commit window (left sidebar or Alt+0)
  4. Right-click on changed files
  5. Choose "Copy File Content to Clipboard"

βš™οΈ Settings

Access settings at: Settings/Preferences > Search for "Copy File Content Settings"

Text Structure

Header Format

  • Default: // file: $FILE_PATH
  • Description: Template for file headers in the output
  • Variables: $FILE_PATH - relative path from project root
  • Example: Change to ### $FILE_PATH ### for Markdown headers

Pre Text

  • Default: (empty)
  • Description: Text added at the very beginning of the copied content
  • Use case: Add context like "=== CODE CONTEXT ===" or project information

Post Text

  • Default: (empty)
  • Description: Text added at the very end of the copied content
  • Use case: Add footers or closing markers

Add Extra Line Between Files

  • Default: Enabled βœ…
  • Description: Adds an empty line between each file's content for better readability

Constraints for Copying

Set Maximum Number of Files

  • Default: Enabled βœ… (30 files)
  • Description: Limits the maximum number of files to copy
  • Purpose: Prevents excessive memory usage and clipboard overflow
  • Recommendation: Keep enabled for safety

Maximum File Size (KB) ⭐ NEW in v0.1.7

  • Default: 500 KB
  • Description: Sets the maximum size (in kilobytes) for individual files to be copied
  • Purpose: Prevents copying very large files that could cause performance issues or memory problems
  • Range: Any positive integer (recommended: 100-10,000 KB)
  • Use cases:
    • 500 KB (default) - Handles most source files including large CSS/JS files
    • 1000 KB (1 MB) - For projects with large generated files
    • 100 KB - Conservative setting for better performance with large codebases
  • Note: Files larger than this limit are silently skipped and logged

Enable File Extension Filtering

  • Default: Disabled
  • Description: When enabled, only copies files with specified extensions
  • How to use:
    1. Check "Enable file extension filtering"
    2. Click Add to add extensions
    3. Enter extensions like .java, .kt, .md, etc.
    4. Use Remove to delete unwanted filters

File Reading Behavior

Strict Memory Reading ⭐ NEW in v0.1.6

  • Default: Enabled βœ… (Strict mode)
  • Description: Controls how the plugin reads file content

Strict Mode (Enabled):

  • βœ… Only reads from memory if file is currently open in an editor tab
  • βœ… Reads from disk if file is closed
  • βœ… More predictable behavior
  • ❌ Slightly slower for closed files

Non-Strict Mode (Disabled):

  • βœ… Reads from IntelliJ's document cache even if tab is closed
  • βœ… Better performance (avoids disk I/O)
  • βœ… Still captures unsaved changes from recently edited files
  • ❌ May read cached version instead of disk version for closed files

Recommendation: Keep strict mode enabled unless you need the extra performance and understand the caching behavior.


Information Display

Show Notification After Copying

  • Default: Enabled βœ…
  • Description: Shows a notification balloon with copy statistics
  • Statistics shown:
    • Number of files copied
    • Total characters
    • Total lines
    • Total words
    • Estimated token count (useful for LLM context limits)

πŸ“– Examples

Example 1: Basic File Copy

Input: Right-click on Main.java

Output:

// file: src/Main.java
public class Main {
    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

Example 2: Multiple Files with Custom Header

Settings: Header format = ### File: $FILE_PATH

Input: Select Main.java and Helper.java

Output:

### File: src/Main.java
public class Main {
    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

### File: src/utils/Helper.java
public class Helper {
    public static String format(String text) {
        return text.trim();
    }
}

Example 3: With Pre and Post Text

Settings:

  • Pre-text: === PROJECT CONTEXT ===
  • Post-text: === END OF CONTEXT ===

Output:

=== PROJECT CONTEXT ===
// file: src/Main.java
[file content]

=== END OF CONTEXT ===

Example 4: Unsaved Changes (v0.1.6+)

Scenario:

  1. Open Main.java in editor
  2. Add line: // TODO: implement feature
  3. Don't save (white dot on tab)
  4. Right-click file in project tree β†’ Copy

Result: βœ… Unsaved changes are included in the output!


πŸ”§ Development and Testing

Requirements

  • Java 21 or higher
  • Gradle 9.0+

Build the Plugin

./gradlew build

Output: build/distributions/Copy_File_Content-{version}.zip

Test in Sandbox IDE

./gradlew runIde

This launches a sandboxed IntelliJ IDEA with the plugin installed for testing.

Run Tests

./gradlew test

Code Coverage

./gradlew koverXmlReport

Plugin Verification

./gradlew verifyPlugin

Verifies compatibility with multiple IntelliJ IDEA versions.


πŸ“¦ Creating a Release

Automated Version Update

Use the version update script:

./scripts/update_version.sh

The script will:

  1. Prompt to confirm change notes are updated in plugin.xml
  2. Increment version (or accept custom version)
  3. Update plugin.xml and gradle.properties
  4. Commit changes
  5. Build the project
  6. Create a git tag
  7. Optionally push to origin

Manual Steps

  1. Update <change-notes> in src/main/resources/META-INF/plugin.xml
  2. Update version in gradle.properties
  3. Update version in plugin.xml
  4. Build: ./gradlew build
  5. Upload build/distributions/Copy_File_Content-{version}.zip to JetBrains Marketplace

🎯 Use Cases

For LLM Context Building

Perfect for ChatGPT, Claude, Gemini, etc.:

  1. Select relevant files
  2. Copy with one click
  3. Paste into LLM chat
  4. Token count helps manage context limits

For Code Reviews

  1. Select files in pull request
  2. Copy content
  3. Paste into review comments
  4. Include file paths automatically

For Documentation

  1. Copy code examples from multiple files
  2. Formatted headers make it clear which file each snippet is from
  3. Add custom pre/post text for context

For Sharing via Chat

  1. Copy files
  2. Share formatted code with teammates
  3. Recipients can see exactly which files the code is from

πŸ†• What's New in v0.1.7

New Features

  • Configurable File Size Limit: Set maximum file size (KB) for copying individual files (default 500 KB, previously hardcoded to 100 KB)
    • Allows copying larger CSS, JS, and generated files
    • Prevents performance issues with extremely large files
    • Fully customizable in settings

Previous Release (v0.1.6)

  • Strict Memory Reading Mode: Control whether files are read only when open in editor (strict) or from document cache (non-strict)
  • VCS Integration: Copy files from VCS Changes/Commit window and VCS Log
  • In-Memory File Reading: Automatically captures unsaved changes in open files
  • Enhanced settings UI with "File Reading Behavior" section
  • Fixed action group warnings for better IDE compatibility

πŸ› οΈ Technical Details

Supported IDEs

  • IntelliJ IDEA (Community & Ultimate)
  • WebStorm
  • PyCharm
  • PhpStorm
  • RubyMine
  • CLion
  • GoLand
  • Rider
  • Android Studio
  • And all other JetBrains IDEs!

Compatibility

  • Minimum version: IntelliJ IDEA 2022.3.3 (Build 223)
  • Tested up to: IntelliJ IDEA 2025.2
  • JVM: Requires Java 21 runtime (automatically provided by IDE)

Platform

  • Language: Kotlin
  • Build System: Gradle with IntelliJ Platform Plugin 2.x
  • Plugin SDK: IntelliJ Platform SDK

πŸ“„ License

This plugin is licensed under the MIT License.


πŸ’¬ Support


πŸ‘€ Author

Marcelo W. Guerra


πŸ™ Contributors

Thank you to all contributors who have helped make this plugin better!

See the Contributors page for the full list.


πŸ”— Links


Plugin based on the IntelliJ Platform Plugin Template

About

Copy File Content is a plugin for IntelliJ IDEs that allow you to quickly copy the contents of selected files and directories to the clipboard, formatted according to customizable settings.

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •