toggle-comment

toggle-comment is a utility designed around setting or toggling the line-comment status of lines in plain text files in a do-what-I-mean fashion. It aims for muscle-memory compatibility with GNU sed.

Examples

``` $ cat > example.py <<'EOF' def greet(name): # Give salutations return f'Hello, {name}!'

print(greet('world')) EOF $ toggle-comment '/def/,/return/' example.py

def greet(name):

# Give salutations

return f'Hello, {name}!'

print(greet('world')) $ toggle-comment '1,3' example.py | toggle-comment '4,5!' def greet(name): # Give salutations return f'Hello, {name}!'

print(greet('world')) ```

Caveats