All of the lines with comments in a file begin with #
. How can I delete all of the lines (and only those lines) which begin with #
? Other lines containing #
, but not at the beginning of the line should be ignored.
If you're at the end of a line and want to select the complete line, use the shortcut key combination Shift + Home . If there's only one line of text in the document, or you want to delete all text, press Ctrl + A key to select all text. Once highlighted, press delete to delete everything.
Delete lines or connectorsClick the line, connector, or shape that you want to delete, and then press Delete. Tip: If you want to delete multiple lines or connectors, select the first line, press and hold Ctrl while you select the other lines, and then press Delete.
First, bring your cursor to the line you want to delete. Press the “Esc” key to change the mode. Now type, “:d”, and press “Enter” to delete the line or quickly press “dd”.
This can be done with a sed one-liner:
sed '/^#/d'
This says, "find all lines that start with # and delete them, leaving everything else."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With