博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Source Insight 宏-单行注释
阅读量:4180 次
发布时间:2019-05-26

本文共 1896 字,大约阅读时间需要 6 分钟。

 

   以前用VS2005或是VS2008写代码,习惯了它的注释功能,使用Source Insight后发现没有提供相应的功能,只能自己写宏来实现,下面就是插入单行注释的宏脚本。

   功能:对选中的内容进行单行注释(//)

   使用:将下面宏脚本写到Source Insight的utils.em文件(Source Insight\Projects\Base下)或是新建一个*.em文件,并加入到Base项目中,通过Key Assignments指定快捷键或是Menu Assignments指定菜单项。

 

  目的:宏的编写纯粹是为了开发的便利,多行注释(/**/)宏,后续会继续做出来。

 

  写的比较乱,但是功能很好用,希望对大家有用,欢迎大家拍!

    

// 插入单行注释macro Comments_UnComments(){	hwnd = GetCurrentWnd()	hbuf = GetCurrentBuf()	if(hbuf ==0)		stop 			// debugBuf只是为了调试	// debugBuf = NewBuf("debugBuf") 	// ClearBuf(debugBuf) 	lnSelFirst = GetWndSelLnFirst(hwnd)		// 获得选中内容的第一行	lnSelLast = GetWndSelLnLast(hwnd) 		// 获得选中内容的最后一行			const_space = " "			// 空格	const_comments = "//" 		// 单行注释符号	isCancelComments = 0 		// 跳过开始的空行,否则下面报错	line_index = lnSelFirst 	orig_text = GetBufLine(hbuf, line_index)	// 获得第一行的text	while(strlen(orig_text) == 0)	{		line_index = line_index + 1		orig_text = GetBufLine(hbuf, line_index)	// 获得第一行的text	}		// 根据第一行选中文本,确定是“注释”,还是“取消注释”	// 判断是否以“//”开始,如果是则认为是“取消注释”,首先需要去掉空格	subIndex = 0 			while(strmid(orig_text, subIndex, subIndex+1) == const_space) 			subIndex = subIndex + 1 		if (strmid(orig_text, subIndex, subIndex+2) == const_comments)	// 以“//”开头,取消注释	{		isCancelComments = 1 	}	// 遍历所有选中的行	// line_index = lnSelFirst 	// 前面已经跳过开头的空行	while(line_index <= lnSelLast)	{		orig_text = GetBufLine(hbuf, line_index)	// 获得以前的text		if (strlen(orig_text) > 0)					// 如果是空行,则跳过		{			dest_text = "" 			if(isCancelComments == 1)					// 取消注释			{				// 查找注释符“//”				subIndex = 0 						while(strmid(orig_text, subIndex, subIndex+1) == const_space) 						subIndex = subIndex + 1 								if (strmid(orig_text, subIndex, subIndex+2) == const_comments)	// 以“//”开头,取消注释				{					dest_text = strmid(orig_text, subIndex+2, strlen(orig_text)) 				}			}			else			{				dest_text = cat("//", orig_text) 			// 添加注释字符 “//”			}			PutBufLine (hbuf, line_index, dest_text)  	// 替换以前的text		}				line_index = line_index + 1  	}}

转载地址:http://szwoi.baihongyu.com/

你可能感兴趣的文章
scrapy爬取图片,自定义图片下载路径和图片名称
查看>>
python3下import MySQLdb出错问题
查看>>
Maven搭建SSM框架(eclipse)
查看>>
synchronized+Integer模拟火车票预售,出现的问题总结
查看>>
沉浸式过山车,感受巨蚁数字心灵的激情
查看>>
htmlunit爬取js异步加载后的页面
查看>>
修改Linux系统locale设置
查看>>
linux网络无法连接问题
查看>>
linux 查看ip
查看>>
go中map与xml互转
查看>>
java进程占用CPU过高
查看>>
CSDN-markdown编辑器
查看>>
拷贝整个目录到另一台服务器并排除log目录
查看>>
拜托,面试别再问我跳表了!
查看>>
android ArrayList<String> 转 String[]
查看>>
RecyclerView baseadapter
查看>>
Android中应用程序如何获得系统签名权限
查看>>
Recycler表格(excelPanel)
查看>>
android一行代码实现沉浸式布局效果
查看>>
json, recyclerView问题
查看>>