I know in Vim you can delete all comments in a file with a keyboard shortcut, but I have been unsuccessful finding a similar technique in ST3. This would be particularly useful for gemfiles and other files that have distracting comments everywhere.
Looking for a keyboard shortcut or a quick and easy alternative.
Any suggestions?
Multiple Selections To select multiple regions using the keyboard, select a block of text, then press Ctrl+Shift+L to split it into one selection per line. When you're done with using multiple selections, just press Ctrl+K to trim all but the first.
To quickly delete a line in your code, place your cursor anywhere in the line and hit Ctrl–Shift–K (Mac and Windows).
The simplest is to use a regex search-and-replace, e.g.,
^#.*\n
Note 1
This won't work for comment blocks. For them you need to be a bit trickier, (very) roughly:
=begin(.|\n)*=end
(Not tested robustly.)
If you do this a lot (which IMO is a little strange) you could bind it to a key.
Note 1: This works for comments at the beginning of lines. It doesn't do comments appended to code lines; if you want to handle that then you can remove the ^
but you'll need to so something about the EOLs that would disappear during replacement. Or you can just ignore the EOL and have some blank lines where line comments were.
What Dave answered didn't work for me. So do the following if its the same case for you too,
To delete all specific <tag> element including contents inside it:
Find What:
RE syntax to work with a particular tag,
(?s)<start tag>.*?<end tag>
Such as, for CSS comment tags,
(?s)/*.*?*/
For HTML comment tags,
(?s)<!--.*?-->
Replace With: Leave the field blank
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