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

Comment Hooks

yohan-pg

|
19 installs
| (0) | Free
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Comment Hooks

Add bash hooks to file operations (open/save/close) using comments within them.

Examples

#on save: make
#on open close: echo $(date) > timestamp.txt

def main():
    ...

Multiple hooks can be included in the same file. The following comment types are supported: "<!--", "#", "//", "--", "%", "(*".

Environment Variables

Hooks have access to the following environment variables:

  • $file (the absolute file path)
  • $relativeFile (the file path relative to the current workspace)
  • $hookType (either 'open' 'save' or 'close' based on which hook was executed)
  • $workspaceFolder (the path to the current workspace).
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft