一、常用配置
1.绿色主题
Options->Preferences->Colors&Fonts->Window Background->Pick Color
设置自定义颜色,添加到自定义颜色,依次确定
红199,绿237,蓝204
色调85,饱和度123,亮度204
2.字体大小不一致
View -> Mono Font View
3.去缩略导航栏
View->Overview
4.显示行号
View->Line Numbers
5.快速主题设置
Options->Visual Theme
6.多行注释
参考函数宏配置快捷键
7.xx\xx\file has line endings that are not consistent.Do you want to normalize it ?
提示行尾不一致
关闭提示
8.打开工程文件显示乱码
keil的工程文件转到sourceinsight,内容显示乱码
操作办法
当前文件修改:File->Reload As EnCoding,把UTF8改成ANSI或GB2312
全局修改:Options->Preferences->Files,other,Default encoding修改成ANSI或GB2312
9.换行使用4个空格,不使用tab
Options->File Type Options->Auto Indenting->Simple
常用Editing Options配置
Enter inserts new line:enter 插入新行
Show line numbers:显示行号
Visible tabs:显示tab
Visible spaces:显示空格
Show right margin:显示右边界
margin width:边界宽度,120字符,语言规范
10.全局配置保存和加载
保存:Options->Save Configuration->(all)->Continue
加载:Options->Load Configuration
二、常用快捷键
1.字体大小不一致
Alt+F12
2.当前页面查找
Ctrl+f
3.加载文件全局查找
右键->Lookup References
Ctrl+/
4.回退/前进
栈的原理前进后退浏览过的位置
前进Alt+,
后退Alt+.
右下方Alt上面两个,前进后退,常配合Ctrl+左键,快速查看代码
5.跳转到定义的位置
鼠标右键->Jump to Definition
Ctrl+鼠标左键
Ctrl+=
6.跳转到调用位置
鼠标右键->Jump to Caller
Ctrl+Alt+c
自定义Ctrl+鼠标右键,搭配前进后退,Ctrl+左键,快速查看代码
7.当前页面跳转到指定行
Ctrl+g
8.保存
保存当前页面Ctrl+s
保存全部页面Ctrl+Alt+a
9.更新链接文件
Alt+Shift+s
10.高亮关键字
F8
常自定义使用鼠标中键高亮,快速查看代码
三、自定义快捷键
3.1 自定义设定快捷键
Options->Key Assignments
3.2 函数宏实现快捷键
这里提四种函数宏实现注释
(1)使用“//”实现多行注释
(2)使用“#ifdef 0”和“#endif”实现多行注释
(3)使用"/* */”实现一行注释
(4)使用“/**/"将一行中鼠标选中部分注释
食用方法:打开sourceinsight,打开项目Base,创建文件comment.em,宏函数拷贝进去,保存起来,再添加该文件到Base项目中,Shift+Alt+s,更新文件,全部保存,打开Key Assignments,搜索Macro,就会看到添加的函数宏了,设定自己想要的快捷键即可。
以下是宏函数
// 使用“//”实现多行注释的宏代码
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)
}
// 使用“#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)
}
参考
以上为个人整理总结的知识,如有遗漏或错误欢迎留言指出、点评,如要引用,请联系通知,未经允许谢绝转载。