`
hududumo
  • 浏览: 242724 次
文章分类
社区版块
存档分类
最新评论

source Insight常用自定义命令和一些小技巧

 
阅读更多

在Source Insight中添加自定义功能的步骤如下:
1.Source Insight中,Options->Custom Commands...->Add...,New Command name 随便写,我的是"Edit with Vim"
2.Run中写入: "C:/Program Files/Vim/vim63/gvim.exe" --remote-silent +%l %f
意思是在当前已经打开的gvim窗口里面打开当前的文件,并且跳转到指定行
%l为当前的行号,%f为文件名
使用 --remote-silent 的作用是,如果已经打开了对应文件,就不会打开第二次,而是在已经打开的文件里跳转到对应行
3.还是同一个对话框里面,选择Keys->Assign New Key...->按F12,如果你已经将F12设置给其他命令,选择其他的按键就行了

下面是一些常用自定义功能:( CUSTOM COMMANDS )

打开资源管理器并选中当前文件
ShellExecute open explorer /e,/select,%f
查看log
"C:/Program Files/TortoiseSVN/bin/TortoiseProc.exe" /command:log /path:%f /notempfile /closeonend
diff
"C:/Program Files/TortoiseSVN/bin/TortoiseProc.exe" /command:diff /path:%f /notempfile /closeonend
取得锁定(check out)
"C:/Program Files/TortoiseSVN/bin/TortoiseProc.exe" /command:lock /path:%f /notempfile /closeonend
提交(check in)
"C:/Program Files/TortoiseSVN/bin/TortoiseProc.exe" /command:commit /path:%f /notempfile /closeonend
更新(update)
"C:/Program Files/TortoiseSVN/bin/TortoiseProc.exe" /command:update /path:%f /notempfile /closeonend
更新整个目录(update all)
"C:/Program Files/TortoiseSVN/bin/TortoiseProc.exe" /command:update /path:*.* /notempfile /closeonend
取消锁定(undo check out)
"C:/Program Files/TortoiseSVN/bin/TortoiseProc.exe" /command:revert /path:%f /notempfile /closeonend
在ultriEdit中编辑
"C:/Program Files/UltraEdit-32/uedit32" %f
在vim中编辑并定位到当前行
"C:/Program Files/Vim/vim63/gvim.exe" --remote-silent +%l %f

汇总其他小技巧:

让{ 和 } 不缩进:

Options->Document Options->Auto Indent->Indent Open Brace/Indent Close Brace

hao space: SourceInsight 小技巧
1、按住"ctrl", 再用鼠标指向某个变量,点击一下,就能进入这个变量的定义。

2、今天把一个用sourceinsight排版整齐的C文件,偶然用VC打开一看,全乱了。研究了半天,发现SI对每个字符的宽度不太一致。
请教同事发现选上"view --> draft view", 就可以让每个字符的宽度一致了。快捷键是 "Alt + F12"

3、"shift+F8" 标亮所有文本中光标所在位置的单词

4、跳到某一行:"ctrl + g"

Source Insight是阅读和编写代码的好东东,基本上也算得上是经典之作了,虽然还有一点点小bug,不过对于我们这些C程序员来说可是一旦拥有别无所求。下 列小技巧是在工作中同事整理总结的,对提高工作效率多少有点帮助,其中有些是对应于SVN的,没有使用SVN做版本管理的人就不要白费力气了。

ShellExecute open explorer /e,/select,%f
/*作用是在资源管理器中打开当前编辑文件并选中*/
/*可以设置快捷键如ctrl+e,这样能很方便的在资源管理器打开对应的文件,并进行tortoiseSVN的相关操作*/

X:/Progra~1/TortoiseSVN/bin/TortoiseProc.exe /command:log /path:% /notempfile /closeonend
/*使用前注意更改对应的bin安装路径*/
/*作用是直接查看当前文件的svn log*/
/*可以设置快捷键如ctrl+l*/

X:/Progra~1/TortoiseSVN/bin/TortoiseProc.exe /command:diff /path:% /notempfile /closeonend
/*使用前注意更改对应的bin安装路径*/
/*作用是直接查看当前文件和基准版本的比较*/
/*可以设置快捷键如ctrl+d*/

在Source Insight中快速添加注释
将以下代码保存成Utils.em,详细使用说明看文章结尾

/* Utils.em - a small collection of useful editing macros */

/*-------------------------------------------------------------------------
I N S E R T H E A D E R

Inserts a comment header block at the top of the current function.
This actually works on any type of symbol, not just functions.

To use this, define an environment variable "MYNAME" and set it
to your email name. eg. set MYNAME=raygr
-------------------------------------------------------------------------*/
macro InsertHeader()
{
// Get the owner's name from the environment variable: MYNAME.
// If the variable doesn't exist, then the owner field is skipped.
szMyName = getenv(MYNAME)

// Get a handle to the current file buffer and the name
// and location of the current symbol where the cursor is.
hbuf = GetCurrentBuf()
szFunc = GetCurSymbol()
ln = GetSymbolLine(szFunc)

// begin assembling the title string
sz = "/* "

/* convert symbol name to T E X T L I K E T H I S */
cch = strlen(szFunc)
ich = 0
while (ich < cch)
{
ch = szFunc[ich]
if (ich > 0)
if (isupper(ch))
sz = cat(sz, " ")
else
sz = cat(sz, " ")
sz = Cat(sz, toupper(ch))
ich = ich + 1
}

sz = Cat(sz, " */")
InsBufLine(hbuf, ln, sz)
InsBufLine(hbuf, ln+1, "/*-------------------------------------------------------------------------")

/* if owner variable exists, insert Owner: name */
if (strlen(szMyName) > 0)
{
InsBufLine(hbuf, ln+2, " Owner: @szMyName@")
InsBufLine(hbuf, ln+3, " ")
ln = ln + 4
}
else
ln = ln + 2

InsBufLine(hbuf, ln, " ") // provide an indent already
InsBufLine(hbuf, ln+1, "-------------------------------------------------------------------------*/")

// put the insertion point inside the header comment
SetBufIns(hbuf, ln, 4)
}


/* InsertFileHeader:

Inserts a comment header block at the top of the current function.
This actually works on any type of symbol, not just functions.

To use this, define an environment variable "MYNAME" and set it
to your email name. eg. set MYNAME=raygr
*/

macro InsertFileHeader()
{
szMyName = getenv(MYNAME)

hbuf = GetCurrentBuf()

InsBufLine(hbuf, 0, "/*-------------------------------------------------------------------------")

/* if owner variable exists, insert Owner: name */
InsBufLine(hbuf, 1, " ")
if (strlen(szMyName) > 0)
{
sz = " Owner: @szMyName@"
InsBufLine(hbuf, 2, " ")
InsBufLine(hbuf, 3, sz)
ln = 4
}
else
ln = 2

InsBufLine(hbuf, ln, "-------------------------------------------------------------------------*/")
}



// Inserts "Returns True .. or False..." at the current line
macro ReturnTrueOrFalse()
{
hbuf = GetCurrentBuf()
ln = GetBufLineCur(hbuf)

InsBufLine(hbuf, ln, " Returns True if successful or False if errors.")
}



/* Inserts ifdef REVIEW around the selection */
macro IfdefReview()
{
IfdefSz("REVIEW");
}


/* Inserts ifdef BOGUS around the selection */
macro IfdefBogus()
{
IfdefSz("BOGUS");
}


/* Inserts ifdef NEVER around the selection */
macro IfdefNever()
{
IfdefSz("NEVER");
}


// Ask user for ifdef condition and wrap it around current
// selection.
macro InsertIfdef()
{
sz = Ask("Enter ifdef condition:")
if (sz != "")
IfdefSz(sz);
}

macro InsertCPlusPlus()
{
IfdefSz("__cplusplus");
}


// Wrap ifdef <sz> .. endif around the current selection
macro IfdefSz(sz)
{
hwnd = GetCurrentWnd()
lnFirst = GetWndSelLnFirst(hwnd)
lnLast = GetWndSelLnLast(hwnd)

hbuf = GetCurrentBuf()
InsBufLine(hbuf, lnFirst, "#ifdef @sz@")
InsBufLine(hbuf, lnLast+2, "#endif /* @sz@ */")
}


// Delete the current line and appends it to the clipboard buffer
macro KillLine()
{
hbufCur = GetCurrentBuf();
lnCur = GetBufLnCur(hbufCur)
hbufClip = GetBufHandle("Clipboard")
AppendBufLine(hbufClip, GetBufLine(hbufCur, lnCur))
DelBufLine(hbufCur, lnCur)
}


// Paste lines killed with KillLine (clipboard is emptied)
macro PasteKillLine()
{
Paste
EmptyBuf(GetBufHandle("Clipboard"))
}



// delete all lines in the buffer
macro EmptyBuf(hbuf)
{
lnMax = GetBufLineCount(hbuf)
while (lnMax > 0)
{
DelBufLine(hbuf, 0)
lnMax = lnMax - 1
}
}


// Ask the user for a symbol name, then jump to its declaration
macro JumpAnywhere()
{
symbol = Ask("What declaration would you like to see?")
JumpToSymbolDef(symbol)
}


// list all siblings of a user specified symbol
// A sibling is any other symbol declared in the same file.
macro OutputSiblingSymbols()
{
symbol = Ask("What symbol would you like to list siblings for?")
hbuf = ListAllSiblings(symbol)
SetCurrentBuf(hbuf)
}


// Given a symbol name, open the file its declared in and
// create a new output buffer listing all of the symbols declared
// in that file. Returns the new buffer handle.
macro ListAllSiblings(symbol)
{
loc = GetSymbolLocation(symbol)
if (loc == "")
{
msg ("@symbol@ not found.")
stop
}

hbufOutput = NewBuf("Results")

hbuf = OpenBuf(loc.file)
if (hbuf == 0)
{
msg ("Can't open file.")
stop
}

isymMax = GetBufSymCount(hbuf)
isym = 0;
while (isym < isymMax)
{
AppendBufLine(hbufOutput, GetBufSymName(hbuf, isym))
isym = isym + 1
}

CloseBuf(hbuf)

return hbufOutput

}

/*

written by yubind

*/

macro SingleLineComment()
{
szMyName = "chenjsa"
// Get a handle to the current file buffer and the name
// and location of the current symbol where the cursor is.
hbuf = GetCurrentBuf()
ln = GetBufLnCur(hbuf)

// Get current time
szTime = GetSysTime(1)
Hour = szTime.Hour
Minute = szTime.Minute
Second = szTime.Second
Day = szTime.Day
Month = szTime.Month
Year = szTime.Year
if (Day < 10)
szDay = "0@Day@"
else
szDay = Day
//szMonth = NumToName(Month)
if (Month < 10)
szMonth = "0@Month@"
else
szMonth = Month

szDescription = Ask("请输入修改原因")
// begin assembling the title string
InsBufLine(hbuf, ln+1, "/*@szDescription@ @szMyName@.xmyanfa @Year@-@szMonth@-@szDay@*/")
}

macro MultiLineCommentHeader()
{
szMyName = "chenjsa"
// Get a handle to the current file buffer and the name
// and location of the current symbol where the cursor is.
hbuf = GetCurrentBuf()
ln = GetBufLnCur(hbuf)

// Get current time
szTime = GetSysTime(1)
Hour = szTime.Hour
Minute = szTime.Minute
Second = szTime.Second
Day = szTime.Day
Month = szTime.Month
Year = szTime.Year
if (Day < 10)
szDay = "0@Day@"
else
szDay = Day
//szMonth = NumToName(Month)
if (Month < 10)
szMonth = "0@Month@"
else
szMonth = Month

szDescription = Ask("请输入修改原因:")
// begin assembling the title string
InsBufLine(hbuf, ln + 1, "/*@szDescription@ @szMyName@.xmyanfa @Year@-@szMonth@-@szDay@ begin*/")
}

macro MultiLineCommentEnd()
{
szMyName = "chenjsa"
// Get a handle to the current file buffer and the name
// and location of the current symbol where the cursor is.
hbuf = GetCurrentBuf()
ln = GetBufLnCur(hbuf)

// Get current time
szTime = GetSysTime(1)
Hour = szTime.Hour
Minute = szTime.Minute
Second = szTime.Second
Day = szTime.Day
Month = szTime.Month
Year = szTime.Year
if (Day < 10)
szDay = "0@Day@"
else
szDay = Day
//szMonth = NumToName(Month)
if (Month < 10)
szMonth = "0@Month@"
else
szMonth = Month

InsBufLine(hbuf, ln + 1, "/*@szMyName@.xmyanfa @Year@-@szMonth@-@szDay@ end*/")
}

使用说明:可以实现在sourceinsight中快速添加修改注释。

1. Project->Open Project... 打开Base工程(该工程一般在我的文档//Source Insight//Projects//Base中);
2. 搜索utils.em 里的字串"chenjsa" 改成自己的姓名
3. Project->Add and Remove Project Files... 加入宏文件(即utils.em);
4. Options->Menu Assignments 打开Menu Assignments窗口, 在Command中输入Macro, 选中要使用的宏(SingleLineComment ,MultiLineCommentHeader,MultiLineCommentEnd), 添加到合适的菜单中.

分享到:
评论

相关推荐

    Source Insight小技巧

    以下是一些关于Source Insight的实用小技巧,可以帮助你更高效地使用它: 1. **背景色选择** - 你可以自定义Source Insight的背景颜色以适应个人喜好或减轻眼睛疲劳。操作路径为:`Options -&gt; Preference -&gt; ...

    source Insight快捷键及使用技巧大全

    ### Source Insight 快捷键及使用技巧大全 #### 一、概述 Source Insight(简称SI)是一款非常强大的源代码编辑器和项目管理工具,广泛应用于软件开发领域,特别是在C/C++编程方面。它通过直观的界面和丰富的功能...

    Source Insight 3.5黑色主题

    Source Insight有一个活跃的用户社区,开发者们会分享自定义的主题、插件和技巧。此外,官方也会定期发布更新,修复已知问题,提升用户体验。 总的来说,Source Insight 3.5的黑色主题结合了强大的功能和舒适的工作...

    Source Insight 3.5安装包 + 激活码

    **Source Insight 3.5** 是一款广受欢迎的源代码编辑器和分析工具,尤其在软件开发领域中,它被程序员广泛用于查看、理解和修改各种编程语言的源代码。这款强大的工具提供了丰富的功能,包括代码高亮、语法智能提示...

    Source_Insight教程及技巧(大全)——最终整合版_insight_Sourceinsight_sourceinsig

    在提供的"Source_Insight教程及技巧(大全)——最终整合版.pdf"中,包含了详细的使用指南、常见问题解答和实用技巧,帮助你更高效地使用Source Insight。 ### 结论 Source Insight是一款强大的源代码编辑器,其丰富...

    source Insight---- Quicker

    Source Insight是一款广受程序员喜爱的源代码查看和编辑工具,尤其在C/C++、Java等语言的开发中,它的智能高亮、语法分析、代码跳转等功能极大地提高了开发效率。本文将详细介绍如何通过`source Insight quicker.em`...

    sourceinsight 使用指导

    ### SourceInsight 使用指导 #### 一、简介 Source Insight 是一款强大的源代码编辑器和分析工具,它能够帮助开发者更好地理解和管理复杂的项目。本文档将详细介绍如何使用 Source Insight 的基本功能及其各种实用...

    Source Insight教程书

    通过交流和分享,你可以更好地掌握Source Insight的使用技巧。 总的来说,Source Insight是一个强大的代码分析工具,无论你是初学者还是经验丰富的开发者,都能从中受益。通过熟练掌握其各种功能,你将在理解和维护...

    source insight配置模板

    Source Insight是一款强大的源代码查看和编辑工具,尤其受到程序员和软件开发者们的喜爱。它提供了丰富的代码导航、语法高亮、自动完成等功能,极大地提高了代码阅读和理解的效率。本文将详细介绍如何配置Source ...

    Source_Insight教程及技巧

    Source Insight还提供了一些常规的编辑功能,比如撤销(Undo)、重做(Redo)、跳转到指定行(Goto Line)等,这些是大多数文本编辑器都具备的基本功能,但在Source Insight中它们被集成在了代码编辑的环境中,使得...

    Source Insight 软件&汉化&linux;界面配置

    "hf_sourceinsight3.5.rar"这个文件很可能是Source Insight的汉化补丁。首先,你需要下载并解压这个rar文件,然后按照里面的说明文档进行操作。通常,汉化步骤包括替换原程序中的语言文件,如将英文的资源文件替换为...

    Source Insight使用技巧

    掌握Source Insight的使用技巧,不仅仅是记忆快捷键那么简单,更重要的是理解如何利用这些工具提高编码效率、优化代码质量和增强团队协作。通过上述策略的应用,开发者可以在日常工作中更加游刃有余,实现生产力的...

    source insight 经典手册

    通过学习此教程,开发者可以快速掌握Source Insight的使用技巧,提升代码阅读和编辑的效率。 总的来说,Source Insight是一款强大的源代码管理工具,它的多种功能和高度可定制性为软件开发提供了极大的便利。掌握...

    SourceInsight(可改字体大小加汉化版)

    **SourceInsight是一款强大的源代码分析和编辑工具,尤其适合于C/C++、Java和C#等编程语言的开发工作。这款软件以其高效、智能的...对于开发者来说,熟练掌握SourceInsight的使用技巧,将有助于提升编程质量和效率。

    Source Insight 4.0 Config.rar

    4. **Project Management**:项目设置允许用户组织和管理代码文件,包括添加、删除和组织文件夹,以及设置编译命令和依赖关系。 5. **Search and Navigation**:配置搜索和导航选项,如全局查找、最近使用的文件...

    Sourceinsight4.rar

    SourceInsight 4 是一款备受程序员喜爱的源代码查看和编辑工具,尤其适用于C、C++、Java等编程语言。这款软件以其高效的代码浏览、智能的语法高亮、强大的搜索功能以及自定义的代码分析而闻名,是开发人员提升工作...

    Source Insight基本使用方法

    本文将详细讲解Source Insight的主要功能和使用步骤,旨在帮助用户快速掌握这款软件,提高代码阅读和理解效率。 首先,安装Source Insight并启动程序后,用户将看到如图1所示的初始界面。界面上的工程按钮用于展示...

    Source Insight 简单教程视频

    首先,我们打开`sourceinsight使用视频教程.exe`,这是一个视频教程,将通过13分钟的时间,展示如何有效地使用Source Insight。 1. **安装与启动** - 安装Source Insight:下载并运行安装程序,按照提示步骤进行...

    source insight.rar

    Source Insight是一款强大的源代码阅读、分析和编辑工具,尤其受到程序员和软件开发者的喜爱。它以其高效、便捷的代码浏览和智能定位功能,在编程领域中占据一席之地。在本文中,我们将深入探讨Source Insight的核心...

    Source Insight的配置方法

    在“Project”菜单的“Set Compiler”选项中配置编译命令和参数,这样在编辑代码时,Source Insight可以实时反馈编译错误和警告。 8. **配置文件保存与导入**: 如标题所述,配置文件的保存和导入是提高效率的有效...

Global site tag (gtag.js) - Google Analytics