Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save shazahm1/3237eca384a8df491d30402ae6c0e8da to your computer and use it in GitHub Desktop.
Save shazahm1/3237eca384a8df491d30402ae6c0e8da 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.

Remove all HTML comments:

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

or remove all HTML comments and trailing newline if it exists:

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

Search and replace with blank.

Remove all CSS comments:

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

Bonus: Remove blank/empty lines?

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