Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gegeriyadi/b262a25b631c779ac4e5ccfcfa7ca160 to your computer and use it in GitHub Desktop.
Save gegeriyadi/b262a25b631c779ac4e5ccfcfa7ca160 to your computer and use it in GitHub Desktop.

To quickly and easily remove all unwanted comments when using Sublime text, perform a search and replace (CMD, ALT & D) and enter the following. Make sure that regex search is enabled by clicking the small icon in the bottom left that looks like an astrix.

For example, to remove all HTML comments:

(?s)<!--.*?-->

search and replace with blank

Or to remove all CSS comments:

(?s)\/\*.*?\*\/

Bonus: How to delete blank/empty lines?

^\n
@shazahm1
Copy link

shazahm1 commented Jan 5, 2023

Thanks!!! Here's a minor tweak to remove all HTML comments and the trailing newline/return, if it exists:

(?s)<!--.*?-->\n?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment