在source insight中添加多行注释和快速添加#if 0的方法

1,添加函数

project-》open project中打开Base,在utils.em文件中添加:MultiLineComment和AddMacroComment函数

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)

}

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

}

2,option-》menu assignment中的work中添加MultiLineComment和AddMacroComment,如下图。然后使用时打开work就可以了。

时间: 2024-08-11 01:06:05

在source insight中添加多行注释和快速添加#if 0的方法的相关文章

Source Insight中的多行注释

我们经常要对一整段代码进行注释,很多代码编辑器都提供了这样的功能:用快捷键"Ctrl + /"来实现"//"的多行注释. 但是在用source insight的时候,发现竟然没有这样的功能.于是在网上搜了一下,sourceinsight里面的多行注释可以用宏来实现. 以下是实现多行注释的宏代码(在别的网站copy过来的,经过测试,还是很好用的): macro MultiLineComment() { hwnd = GetCurrentWnd() selection

source insight 中添加指定类型文件

source insight 中过滤某些格式的文件. 建立source insight工程后,先暂时不要急于添加文件. 打开options->document options,在document type中选择我们不需要的文件格式点击remove type 将其删除. 然后点击Close,至此我们可以放心添加文件了. 点击project ->add and remove project Files. 选中要添加的文件目录,点击Add Tree..简单方面.source insight 将自动递

Source Insight 中使用 AStyle 代码格式工具

Source Insight 中使用 AStyle 代码格式工具 彭会锋 2015-05-19 23:26:32     Source Insight是较好的代码阅读和编辑工具,不过source insight没有集成代码格式化工具:GNU的astyle是一个较好的免费的代码格式化工具,经过它的格式化之后,代码排版会变得很漂亮:Astyle主要作为插件供其他程序调用,具体的使用方法如下: 1 astyle下载地址: http://sourceforge.net/projects/astyle/

友坚4412开发板怎样在source insight中使汇编代码高亮显示?

友坚4412开发板怎样在source insight中使汇编代码高亮显示?4412开发板 做ARM嵌入式开发时,有时得整汇编代码,但在SIS里建立PROJECT并ADD TREE的时候,根据默认设置并不会把该TREE里面所有汇编文件都包含进来,默认只加了.inc和.asm后缀的, .s后缀的没有.而且用SIS打开.s的文件时,一片黑白没有色彩, 感觉回到DOS的EDIT时代里了. 解决方法是在Options->Document Options里面,点左上的Document Type下拉菜单,选择

在source insight中集成astyle

转自:http://www.cnblogs.com/xuxm2007/archive/2013/04/06/3002390.html 好吧,我有代码格式的强迫症,代码不整齐,我看的都头疼,之前一直喜欢用SourceStyler C++的,但是这个在win7下貌似不能使用,只能转向astyle了. http://www.cnblogs.com/xuxm2007/archive/2010/09/21/1832686.html 关于参数的话,差不过够用就行,不用非得调的那么精细,比较重要的是要看代码啊

Source Insight 中的 Auto Indenting

编码过程中,希望输入花括号时能自动对齐,Source Insigth 应如何设置? 先来看一下Source Insight 中的帮助. “ Auto Indenting The auto-indenting feature controls the level of indentation as you type new text. Source Insight supports Simple and Smart types of auto-indentation. Not all langua

ubuntu14.04中 gedit 注释能显示中文,而source insight中显示为乱码的解决办法

1.乱码显示情况: 2.用gedit打开文件,并用ctrl+shift+s(另存为),其中charactor coding选为chinese simplified(GB2312); 2.修改个文件名, 并点击save. 3.用source insight打开,看看是不是不是乱码了? - - 4.这个我可搞了好几天,嘿嘿~~~

ubuntu中source insight打不开,报错pagefault的解决方法

在ubuntu中装了source insight用来看代码. 但用了一段时间后,有一天突然就发现打不开了,打开马上会弹出wine的错误,详细信息里面是什么PageFault 0x0000008之类的,下面跟着很长的一堆内存地址. google百度,重装wine,重装source insight,都不好使. 最后觉得肯定是卸载的时候没删除干净,要置之死地而后生才行啊. 于是找出所有的相关文件删除,再次重装source insight就好了,虽然还是不知道到底做错了什么让它崩溃了的. 总结一下: 升

source insight中快速添加时间到代码

本文章中程序由其他网友代码修改而来, 并非原本原创,总结如下,作为个人笔记使用. (1)打开工程base,打开文件Utils.em,插入以下代码: //插入时间 macro MonthToName(MonthNum) { if (MonthNum== 1) return "01" if (MonthNum== 2) return "02" if (MonthNum== 3) return "03" if (MonthNum== 4) return