Source Insight中的多行注释
转自:http://www.cnblogs.com/dongzhiquan/archive/2013/03/04/2943448.html
我们经常要对一整段代码进行注释,很多代码编辑器都提供了这样的功能:用快捷键“Ctrl + /”来实现“//”的多行注释。
但是在用source insight的时候,发现竟然没有这样的功能。于是在网上搜了一下,sourceinsight里面的多行注释可以用宏来实现。
以下是实现多行注释的宏代码(在别的网站copy过来的,经过测试,还是很好用的):
macro MultiLineComment()
{
hwnd = GetCurrentWnd()
selection = GetWndSel(hwnd)
LnFirst =GetWndSelLnFirst(hwnd) //取首行行号
LnLast =GetWndSelLnLast(hwnd) //取末行行号
hbuf = GetCurrentBuf()
if(GetBufLine(hbuf, 0) =="//magic-number:tph85666031"){
stop
}
Ln = Lnfirst
buf = GetBufLine(hbuf, Ln)
len = strlen(buf)
while(Ln <= Lnlast) {
buf = GetBufLine(hbuf, Ln) //取Ln对应的行
if(buf ==""){ //跳过空行
Ln = Ln + 1
continue
}
if(StrMid(buf, 0, 1) == "/"){ //需要取消注释,防止只有单字符的行
if(StrMid(buf, 1, 2) == "/"){
PutBufLine(hbuf, Ln, StrMid(buf, 2, Strlen(buf)))
}
}
if(StrMid(buf,0,1) !="/"){ //需要添加注释
PutBufLine(hbuf, Ln, Cat("//", buf))
}
Ln = Ln + 1
}
SetWndSel(hwnd, selection)
}
将上面的代码另存为xxx.em文件,打开source insight,将该文件添加到工程中,然后在Options->KeyAssignments中你就可以看到这个宏了,宏的名字是MultiLineComments,然后我们为它分配快捷键“Ctrl + /”,然后就可以了。
这里还有一份添加“#ifdef 0”和“#endif”的宏代码:
macro AddMacroComment()
{
hwnd=GetCurrentWnd()
sel=GetWndSel(hwnd)
lnFirst=GetWndSelLnFirst(hwnd)
lnLast=GetWndSelLnLast(hwnd)
hbuf=GetCurrentBuf()
if (LnFirst == 0) {
szIfStart = ""
} else {
szIfStart = GetBufLine(hbuf, LnFirst-1)
}
szIfEnd = GetBufLine(hbuf, lnLast+1)
if (szIfStart == "#if 0" && szIfEnd =="#endif") {
DelBufLine(hbuf, lnLast+1)
DelBufLine(hbuf, lnFirst-1)
sel.lnFirst = sel.lnFirst – 1
sel.lnLast = sel.lnLast – 1
} else {
InsBufLine(hbuf, lnFirst, "#if 0")
InsBufLine(hbuf, lnLast+2, "#endif")
sel.lnFirst = sel.lnFirst + 1
sel.lnLast = sel.lnLast + 1
}
SetWndSel( hwnd, sel )
}
这份宏的代码可以把光标显示的行注释掉:
macro CommentSingleLine()
{
hbuf = GetCurrentBuf()
ln = GetBufLnCur(hbuf)
str = GetBufLine (hbuf, ln)
str = cat("/*",str)
str = cat(str,"*/")
PutBufLine (hbuf, ln, str)
}
将一行中鼠标选中部分注释掉:
macro CommentSelStr()
{
hbuf = GetCurrentBuf()
ln = GetBufLnCur(hbuf)
str = GetBufSelText(hbuf)
str = cat("/*",str)
str = cat(str,"*/")
SetBufSelText (hbuf, str)
}
最后是source insight与宏有关的资源:
Source Insight中的多行注释的更多相关文章
- source insight中的快捷键总结
1.快捷键 1,Shift+F8高亮显示指定字符. 2,Ctrl+F找出来的结果用F4,F3前进后退查找. 3,Alt+,后退alt+.前进查找关键字. 4,Alt+G或者F5跳转到某个固定的行号. ...
- 在source insight中集成astyle
转自:http://www.cnblogs.com/xuxm2007/archive/2013/04/06/3002390.html 好吧,我有代码格式的强迫症,代码不整齐,我看的都头疼,之前一直喜欢 ...
- Source Insight 中使用 AStyle 代码格式工具
Source Insight 中使用 AStyle 代码格式工具 彭会锋 2015-05-19 23:26:32 Source Insight是较好的代码阅读和编辑工具,不过source in ...
- AStyle代码格式工具在source insight中的使用
一.AStyle下载路径 Astyle为开源项目,支持C/C++和java的代码格式化 Home Page: http://astyle.sourceforge.net/ Project Page: ...
- source insight 中tab键的设置
转:http://xinzero.com/source-insight-code-alignment-ended.html source insight代码对齐Tab键终极版 以前也写过一个sourc ...
- Source Insight 中调用Notepad++
options>custom commands 指令为 "E:\Program Files (x86)\Notepad++\notepad++.exe" %f 其中%f表示S ...
- Source Insight 中的 Auto Indenting
编码过程中,希望输入花括号时能自动对齐,Source Insigth 应如何设置? 先来看一下Source Insight 中的帮助. “ Auto Indenting The auto-indent ...
- Source insight 中 标题栏路径显示完整路径的方法
在source insight 的标题栏中显示完整路径名的方法.Options -> Preferences -> Display -> Trim long path names w ...
- ubuntu14.04中 gedit 凝视能显示中文,而source insight中显示为乱码的解决的方法
1.乱码显示情况: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcjc3NjgzOTYy/font/5a6L5L2T/fontsize/400/fill/ ...
随机推荐
- Advanced Find and Replace(文件内容搜索替换工具)v7.8.1简体中文破解版
Advanced Find and Replace是一款文件内容搜索工具,同时也是文件内容批量替换工具.支持通配符和正则表达式,方便快捷强大! 显示中文的方法:第二个菜单-Language-选 下载地 ...
- matplotlib雷达图
用matplotlib画雷达图,网上流传的版本其实都是官网的一个例子.但是那个例子太复杂,而且它封装了几个类,让人难以一眼看出其本质. 我给出一个简单的解决方法,没有任何封装.作本文的原因,是为了回答 ...
- [算法]用JAVA实现快速排序
问题描述: 实现对数组的普通快速排序与随机快速排序实验要求: (1)实现上述两个算法 (2)统计算法的运行时间 (3)分析性能差异,作出总结 代码: 一:普通快速排序 public class Qui ...
- 使用cJSON库解析JSON
cJSON库的下载 cJSON是一个基于C的JSON解析库,这个库非常简单,只有cJSON.c和cJSON.h两个文件,支持JSON的解析和封装,需要调用时,只需要#include "cJS ...
- ModelForm解密
一.复用model表和字段 models.py文件 class User(models.Model): username = models.CharField(max_length=32) emai ...
- 程序员,Python 这次彻底上位了!
在 2018 年底,我们迎来了编程语言的最后一波洗礼.近期 TIOBE 公布了 12 月编程语言排行榜,前三名变为: Java.C.Python. 而在 PYPL 榜单上 Python 在今年 5 月 ...
- Map.containsKey(String key)
判断key有没有对应的value值有,返回true无,返回false
- VRRP+tunnel+IP SLA+Track实现冗余切换
IP SLA(Internet Protocol Service-Level Agreement)互联网服务等级协议,本实验里通过发送测试报文,测试下一跳是否可达,结合Track实现冗余静态路由的切换 ...
- linux下查看端口是否被占用以及查看所有端口
1.查看服务器端口是否被占用 >lsof -i:8081 2.查看服务器所有端口 >netstat -ntlp 3.查看服务器是否开放某端口 tcp端口:>netstat -ntp ...
- Docker创建数据卷
当程序在容器中运行时,需要与其他容器中的程序或者容器外部的程序进行文件读写操作时,就需要进行数据的交换:容器内部的文件系统,是一个临时层,当容器停止运行并被删除时,这个临时层就会被一同丢弃:为了达到从 ...