vscode删除文件夹,VSCode:删除文件中的所有注释
Is there an easy way to delete all comments from an open file in VSCode? Preferably both line and block comments.
Most interested in Java, but also Python and R.
解決方案
Easy way:
Open extensions (ctrl-shift-x)
type in remove comments in the search box.
Install the top pick and read instructions.
Hard way (I guess)
search replace(ctrl-h)
toggle regex on (alt-r).
A simple //.* will match all single line comments (and more ;D). #.* could be used to match python comments. And /\*[\s\S\n]*\*/ matches block comments. And you can combine them as well: //.*|/\*[\s\S\n]*\*/ (| in regex means "or", . means any character, * means "0 or more" and shows how many characters to match, so therefor .* means all characters until the end of the line)
Of course with caveats, such as urls (https://...) has double slashes and will match that first rule, and god knows where there are # in code that will match that python-rule. So some reading/adjusting has to be done!
Once you start fiddling with your regexes it can take a lifetime to get them perfect, so be careful. I'd probably go the easy route if you haven't touched regexes before! But knowing some simple regex by heart will do you good, since it's usable almost everywhere.
總結(jié)
以上是生活随笔為你收集整理的vscode删除文件夹,VSCode:删除文件中的所有注释的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 华三服务器收集系统日志,Rsyslog+
- 下一篇: 怎么分辨学校计算机sql版本,怎么筛选出