超好用的 Visual Studio 批量删除代码注释扩展组件 Comment Remover

在编写程序的过程中,几乎所有人都会遇到需要删除代码中注释的情况。

一行一行删除注释,这个显然效率太低,不能接受。

网上教的方法普遍为使用正则表达式进行替换删除,但效果并不令人满意,这种方法问题在于:

1、很可能(几乎一定)注释删除不干净。注释有很多种种类,包括单行注释【 \\ 】、多行注释【 /**/ 】、XML文档注释【 \\\ 】,多数正则表达式一次只能删除其中一种。

2、由于采用的是替换的方式,在替换注释的同时,必然破坏原先的文档格式,需要在删除注释后重新调整格式,又增加了一道工作量。

在 VisualStudio 的扩展中,发现了一个宝藏扩展组件:Comment Remover,该VS扩展能够比较完美的完成代码注释清理工作。

具体使用方法如下:

一、安装 Comment Remover 扩展

进入VS主界面,依次点击“扩展”--“管理扩展”,搜索 Comment Remover 扩展并安装。

记得安装完成后重启 VisualStudio 。

二、使用扩展进行注释清理

打开项目代码文件后,依次点击“编辑”--“Comments”--“Remove All”,该文件中的各种注释即可全部移除。

移除后效果如下:

非常的工整干净!

C代码注释删除工具,用Lex生成。可删除C源程序中的/* xxxx */的块或单行注释,及C++风格的单行注释,对于常量字符串中出现的注释不清除。文件包含Lex代码及编译的Linux下的可执行文件。编译及使用见Readme。 C注释的类型如下 // /* // * "C-style block comment be removed // * C-style block comment be removed" // * C-style block comment be removed // */ // // /* C-style single line comment be removed */ // // // c++ comment be removed // // ///* c++ comment be removed */ // c++ comment be removed // // // c++ comment enclosed with double-quote untouched // "////*\"c++ comment enclosed with double-quote untouched\" ##*/\n" // // // c-style single line comment enclosed with double-quote untouched // "/*c-style multiple line comment enclosed with double-quote untouched*/\n" // // // c-style multiple line comment enclosed with double-quote untouched // "/** c-style multiple line comment enclosed with double-quote untouched \n\ // \n next line\ // */\n" 示例文件: int main() { /* * "C-style block comment be removed * C-style block comment be removed" * C-style block comment be removed */ /* C-style single line comment be removed */ int foo; /* C-style single line comment be removed */ /* C-style single line comment be removed */ int bar; int foobar; /* "C-style block comment be removed C-style block comment be removed C-style block comment be removed */ // c++ comment be removed ///* c++ comment be removed */ // c++ comment be removed // "////" ???? // "/*test file */" ????? /* ssss /* dddd */ printf("////*\"c++ comment enclosed with double-quote untouched\" ##*/\n"); // c++ comment enclosed with double-quote untouched printf("/*c-style multiple line comment enclosed with double-quote untouched*/\n"); // c-style single line comment enclosed with double-quote untouched // printf("/** test cmnt \n //\n ss //*/"); printf("/** c-style multiple line comment enclosed with double-quote untouched \n\ \n next line\ */\n"); // c-style multiple line comment enclosed with double-quote untouched } 注释删除后成为: int main() { int foo; int bar; int foobar; printf("////*\"c++ comment enclosed with double-quote untouched\" ##*/\n"); printf("/*c-style multiple line comment enclosed with double-quote untouched*/\n"); printf("/** c-style multiple line comment enclosed with double-quote untouched \n\ \n next line\ */\n"); }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值