Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

These regex patterns are **better than most VS Code or VSCodium extensions** for removing comments, as they allow for more control and precision.

License

Notifications You must be signed in to change notification settings

TheHolyOneZ/Python-Comments-Cleaner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

3 Commits

Repository files navigation

Python-Comments-Cleaner

These regex patterns are better than most VS Code or VSCodium extensions for removing comments, as they allow for more control and precision.

1. Full-Line Comments

Regex Pattern:

^\s*#.*$

Description:

Deletes entire lines that contain only comments, including those with leading spaces.

2. In-Line Comments

Regex Pattern:

(?<=\s)#\s+.*$

3. Trailing (Inline) Comments After Code

Regex Pattern:

(?<=\S)\s{2,}#.*$

Description:

Deletes comments that appear after code, but only if there are at least two spaces before the #.


4. Strict Docstring Matching (One-Liner)

Regex Pattern:

"""[^"]+"""

Description: Matches strict one-line docstrings enclosed by triple quotes (""") in function definitions. This ensures it doesn't accidentally match strings or comments.


Usage in VS Code or VSCodium

  1. Open Find/Replace (Ctrl+H)
  2. Turn on Regex mode (the .* button)
  3. Paste the pattern in the "Find" field
  4. Leave "Replace" blank (empty)
  5. Click "Replace All"

About

These regex patterns are **better than most VS Code or VSCodium extensions** for removing comments, as they allow for more control and precision.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

AltStyle によって変換されたページ (->オリジナル) /