Source Insight marco:MultiLineComment

cyang Lv6

一、使用场景

Suorce Insight 中内置了一些实用的快捷键命令,可以在 Options->Key Assignments 中看到。另外,SI 还提供了用户自己添加功能的方法,就是 marco 指令。SI 内置了 13 种快键指令,例如:

1
2
3
Marco: KillLine      //删除整行
Marco: PasteKillLine //粘贴刚刚删除的一行
...

只不过默认这些功能都是没有绑定快捷键的,需要自己添加,例如我习惯把删除单行设置为 ctrl+d。

还有一个比较实用的功能就是多行注释,这个功能是 SI 是没有内置的。不过网上已经有人写好了这个功能的代码,我们添加进 marco 代码文件中就好。代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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)

}

二、添加方法

  • 1、使用 SI 打开 base 工程。
    这里写图片描述
  • 2、可见这个工程中只包含一个文件,即 utils.em ,这个文件就是 marco 功能的代码。内置的 13 个功能的代码都在这里。
    这里写图片描述
  • 3、将上面的代码粘贴到这个文件末尾,保存。此时,多行注释的功能就有了。
    这里写图片描述
  • 4、选中多行后,使用 ctrl+/ 就可以一次注释多行了,再次按下则取消注释。
    这里写图片描述

三、参考链接

Source Insight 多行注释

Source Insight中的多行注释

原文链接:本人CSDN博客

  • 标题: Source Insight marco:MultiLineComment
  • 作者: cyang
  • 创建于 : 2017-03-16 18:38:01
  • 更新于 : 2020-02-19 21:32:58
  • 链接: https://blog.cyang.tech/2017/03/16/Source Insight marco:MultiLineComment/
  • 版权声明: 本文章采用 CC BY-NC-SA 4.0 进行许可。
评论
此页目录
Source Insight marco:MultiLineComment