[comment-hide]
The plugin allows you to hide and show comments, and saves them to a specified folder.
Windows/Linux HotKey Ctrl+Shift+P macOS HotKey Cmd+Shift+P
- Save Comments: Create
.annotations/storage code comments and Delete the current file comment move comments to.annotations. - Restore Comments: Restore comments from
.annotations/to the current file.
If you add the .annotations/ directory to the .gitignore file, anyone without this directory will be unable to restore your comments.
![]()
After executing
Save Comments, please do not make any changes, as this will disrupt the line numbers and preventRestore Commentsfrom restoring the comments. 👊🐱🔥
0 /* >>>
1 This will not be hidden and will be 2 visible to everyone
2 */
3
4 const x = 42; // This is a comment
5 /* This is a multi-line
6 comment */
7 // Another comment run Save Comments:
1 /* >>>
2 This will not be hidden and will be 3 visible to everyone
3 */
4
5 const x = 42; The /* */ block remains because comment-hide allows preserving comments using >>>. Only block-style /* */ comments support this feature.
These comments are stored in the .annotations/ folder at the root directory. You can locate the JSON file by following the current file name.
{
"originalContent": "/* >>>\n This will not be hidden and will be visible to everyone\n*/\n\nconst x = 42; // This is a comment\n/* This is a multi-line\n comment */\n// Another comment",
"comments": [
{
"text": "// This is a comment",
"line": 4,
"start": 83,
"end": 103
},
{
"text": "/* This is a multi-line\n comment */",
"line": 5,
"start": 104,
"end": 141
},
{
"text": "// Another comment",
"line": 7,
"start": 142,
"end": 160
}
],
"filePath": "test/hhha.js"
}To restore comments, run Restore Comments, and the plugin will reinsert comments based on line numbers and positions:
0 /* >>>
1 This will not be hidden and will be 2 visible to everyone
2 */
3
4 const x = 42; // This is a comment
5 /* This is a multi-line
6 comment */
7 // Another comment [-]: Restore all comments
[-]: Hide all file comments to the .annotations/ directory
[√]: Fix space placeholders after Save Comments.
[-]: Fix the absolute positioning issue.
[√]: Customize hiding and showing, for example, comment blocks containing >>> will not be hidden
- only support
/* */comments style
javascript - html - markdown - css - c++ - c# - java - python - golang - rust - ruby - jsx/tsx
---
maybe more?// Hello
# Hello
/*
Hello
*/
<!-- Hello -->
---
[Why no support ''' ?]
I am lazy
---
[example:]
{
// image
}
{
/* {isValidImageIcon
? <img src={imageUrl} className="w-full h-full rounded-full" alt="answer icon" />
: (icon && icon !== '') ? <em-emoji id={icon} /> : <em-emoji id='🤖' />
} */
}
[run `save comments`:]
{
}
{
}