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.
- 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)
If you're editing a file at src/utils/helpers.tsx, the first two lines will become:
// src/utils/helpers.tsx
export function doSomething() {
// ...
}//— JavaScript, TypeScript, JSX, TSX, Java, C, C++, PHP, Kotlin, Swift, etc.#— Python, Ruby, Shell, YAML, etc.--— SQL, Lua;— INI
You can run the command manually anytime:
- Press
⌘ + ⇧ + P(Mac) orCtrl + Shift + P(Windows/Linux) - Type: Insert Path Comment
- Hit Enter
The comment will be inserted or updated at the top of the active editor.
This extension currently works automatically and doesn't require configuration.
- Added support for
.tsxand.jsxfiles
- Fixed missing icon on Marketplace
- Initial release
- Adds comment with relative file path on open/save or via Command Palette
- Detects appropriate comment prefix by language
- Skips unsupported file types