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.
``` $ cat > example.py <<'EOF' def greet(name): # Give salutations return f'Hello, {name}!'
print(greet('world')) EOF $ toggle-comment '/def/,/return/' example.py
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')) ```
regex
crate. Notable differences
are in the (lack of) escapes for special characters, e.g. /a|b/
vs /a\|b/
M~N
"step-wise" patterns, e.g. 1~3
matching lines 1, 4, 7...;addr,~N
"up-to-multiple", e.g. 10,~7
matching lines 10-14; and\|http://|
(initial
backslash followed by delimiter);