This IntelliJ plugin copies a file reference with line numbers to the clipboard for selected text. Perfect for sharing code locations with team members or referencing specific lines in documentation. Compatible with IntelliJ IDEA and WebStorm.
- Simple File Reference: Copies file path with line numbers (e.g., "src/main/MyFile.java:4-10")
- Works with Any File Type: Supports all file types in IntelliJ IDEA and WebStorm
- Relative Paths: Uses relative paths from project root for cleaner references
- Single Line Support: Shows single line numbers when selection is on one line
- Multi-line Support: Shows line ranges when selection spans multiple lines
- Clone this repository
- Open the project in IntelliJ IDEA or WebStorm
- Run
./gradlew buildPluginto build the plugin - Run
./gradlew runIdeto test the plugin in a sandbox IDE instance
- Build the plugin:
./gradlew buildPlugin - Install the generated
.zipfile frombuild/distributions/in IntelliJ IDEA or WebStorm - Go to
File > Settings > Plugins > Installedand enable "Copy Selection Reference"
- Select any text in your editor
- Go to
Edit > Copy Selection Referencein the menu - The file reference is automatically copied to your clipboard
- Select any text in your editor
- Press
Ctrl+Alt+R(Windows/Linux) orCmd+Alt+R(Mac) - The file reference is automatically copied to your clipboard
If you select text on line 5 of src/main/MyClass.java:
- Copied to clipboard:
src/main/MyClass.java:5
If you select text from lines 4 to 10 of src/main/MyClass.java:
- Copied to clipboard:
src/main/MyClass.java:4-10
Works with any file type:
README.md:15-20package.json:3styles.css:25-30script.js:10-15
- CopySelectionReferenceAction: Main action class that handles user interactions and clipboard operations
- Text Selection: User selects text in the editor
- Line Calculation: Plugin calculates start and end line numbers from selection offsets
- Path Resolution: Determines relative file path from project root
- Reference Generation: Creates file reference string with line numbers
- Clipboard Copy: Copies the reference to system clipboard
The plugin requires no configuration - it works out of the box with any file type and project structure.
# Build the plugin
./gradlew buildPlugin
# Run in sandbox IDE
./gradlew runIde
# Run tests
./gradlew testsrc/main/
├── kotlin/com/example/selectionplugin/
│ └── CopySelectionReferenceAction.kt # Main action handler
└── resources/META-INF/
└── plugin.xml # Plugin configuration
- IntelliJ IDEA: 2023.3 and later (build 233.0+)
- WebStorm: 2023.3 and later
- PyCharm: 2023.3 and later
- Android Studio: 2023.3 and later
- Other JetBrains IDEs: Any IDE based on IntelliJ Platform 2023.3+
- Java: 17+
- Kotlin: 1.9.25+
- Supported Languages: All file types supported by the IDE (no language-specific dependencies required)
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Plugin not appearing in menu: Ensure the plugin is enabled in Settings > Plugins
- Nothing copied to clipboard: Make sure you have selected text before running the action
- Build errors: Ensure you're using Java 17+ and compatible IntelliJ version
- Support for different reference formats (absolute paths, git URLs, etc.)
- Configurable reference format through settings
- Integration with issue trackers (JIRA, GitHub, etc.)
- Support for copying multiple selections
- History of copied references