Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Path CommentNew to Visual Studio Code? Get it now.
Path Comment

Path Comment

Michal Fanta

|
5 installs
| (0) | Free
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.
Copied to clipboard
More Info

Path Comment

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() {
  // ...
}

Supported Languages

  • // — JavaScript, TypeScript, JSX, TSX, Java, C, C++, PHP, Kotlin, Swift, etc.
  • # — Python, Ruby, Shell, YAML, etc.
  • -- — SQL, Lua
  • ; — INI

Manual Usage

You can run the command manually anytime:

  1. Press ⌘ + ⇧ + P (Mac) or Ctrl + Shift + P (Windows/Linux)
  2. Type: Insert Path Comment
  3. Hit Enter

The comment will be inserted or updated at the top of the active editor.

Extension Settings

This extension currently works automatically and doesn't require configuration.

Release Notes

1.0.2

  • Added support for .tsx and .jsx files

1.0.1

  • Fixed missing icon on Marketplace

1.0.0

  • 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

💻 Source Code

GitHub Repository

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft