Adds a comment with the file's relative path to the top of each file on open, save, or on command, using the same format as ChatGPT when showing code files.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Adds a comment with the file's relative path to the top of supported files on open, save, or on command.
This helps track file origin when copying code, similar to how ChatGPT formats code examples.
Features
Automatically inserts or updates the relative path comment:
When a file is opened
When a file is saved
When triggered manually via Command Palette
Adds an empty line after the comment for clarity
Supports multiple languages with proper comment prefixes (e.g. //, #, --)
Skips file types that don't support comments (e.g. .md, .html)
Example
If you're editing a file at src/utils/helpers.tsx, the first two lines will become:
// src/utils/helpers.tsx
export function doSomething() {
// ...
}