Rewrite

Remove leading comment markers

Remove the leading # and following spaces from each line.

What this template solves

This template helps you rewrite commented snippets into active lines by removing a repeated prefix at the start of each line.

Open the workspace with this template preloaded, then refine it for your own file and text pattern.

Sample input

# one
# two
#   three

Prompt to start from

Remove the leading # and following spaces from each line

Expected command

sed 's/^#\s*//'

Tags

commentsrewriteprefix

Best for

  • Turn commented config examples into active settings.
  • Normalize copied shell snippets that start with comment markers.
  • Strip repeated prefixes from generated docs or manifests.

How to use this template

  1. 1Verify that every target line begins with the same prefix.
  2. 2Copy the sed expression that removes the prefix from line starts.
  3. 3Test on a short sample before applying the in-place file-edit command.

Template FAQ

How can I remove the same prefix from the start of every line with sed?

A replacement such as `sed 's/^#\s*//'` removes a repeated leading marker from each line. This is useful for turning commented examples into active lines or cleaning repeated prefixes from copied text.

What is the difference between trim-prefix and uncomment-lines?

Trim-prefix is broader and works for any repeated start-of-line marker, while uncomment-lines is a more direct landing page for enabling config lines that begin with a comment symbol like `#`.

Related templates

Explore nearby sed workflows that target similar replace, cleanup, filtering, or rewrite tasks.

Remove leading comment markers Sed Template | AskSed