Source Insight常用快捷键及注释快捷键设置

本文介绍了SourceInsight软件的快捷键设置方法及实用宏的编写技巧,包括单行或多行注释、添加ifdef条件编译指令等功能,帮助提高代码编辑效率。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在使用SI过程中,我根据自己的使用习惯修改了它的默认快捷键,并且在配置文件中添加了一些人性化功能,下面一一介绍:

修改快捷键:Options->Key Assignments...

1.main window:Esc       2.Hight light:Middle Mouse

3.Go Back:Alt+z              4.Go Forward:Alt+x              

5.Caller:Alt+c                  6.Reference:Alt+r

7.Previous Link:Alt+a    8.Next Link:Alt+s

9.First Link:Alt+d          

10.Go Line:Alt+g           11.Select Line:Alt+l

12.Symbol Win:Alt+q    13.Activate SW:Alt+w

14.Projcet Win:Alt+[       15.Activate PW:Alt+]

16.Contex Win:Alt+,     17.Activate CW:Alt+.

18.Relation Win:Alt+;   19.Activate RW:Alt+'

20.Select All:Ctrl+a          21.Save All:Ctrl+Shift+a

22.Browse Project Symbols:Alt+b


添加一些配置文件宏,比如:注释掉代码:单行注释、多行注释,将选中内容注释掉;在一行代码的前、后添加注释性文字等。

打开Projcet->Open project,选择base,可以看到utils.em文件,将下列宏添加到该文件中,并在其他工程里加入该文件,

在上面介绍的快捷键添加方式里找到该宏并自定义快捷键。

单行、多行注释:

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)
}

将上面的代码保存到utils.em文件,打开source insight,将该文件添加到工程中,然后在Options->Key Assignments中你就可以看到这个宏了,宏的名字是MultiLineComments,然后我们为它分配快捷键“Ctrl + /”,然后就可以了。

这是一份添加“#ifdef 0”和“#endif”的宏代码,定义快捷键为Ctrl+#

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 )
}

这份宏的代码可以把光标所在的行注释掉,定义快捷键为Ctrl+*:

macro CommentSingleLine()
{
    hbuf = GetCurrentBuf()
    ln = GetBufLnCur(hbuf)
    str = GetBufLine (hbuf, ln)
    str = cat("/*",str)
    str = cat(str,"*/")
    PutBufLine (hbuf, ln, str)
}

将一行中鼠标选中部分注释掉,定义快捷键为Ctrl+shift+*:

macro CommentSelStr()
{
    hbuf = GetCurrentBuf()
    ln = GetBufLnCur(hbuf)
    str = GetBufSelText(hbuf)
    str = cat("/*",str)
    str = cat(str,"*/")
    SetBufSelText (hbuf, str)
}


在一行代码前添加注释性文字, 定义快捷键为Alt+/:

在一行代码前添加注释性文字,定义快捷键为Alt+\:


最后是source insight与宏有关的资源:

 

 

 

转另一博客中的宏

使用“Options” -- “Menu Assignments” 新建一个菜单项Work,然后把Macro:SetAuthorName, Macro:NewHeaderFileStruct, Macro:NewSrcFileStruct, Macro:InsertFileHeader, Macro:InsertFunctionHeader加入这个自定义的菜单里。

 

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

macro SetAuthorName()
{
	szAuthorName = Ask("Please Input Your Name:")
	szAuthorName = StrTrim(szAuthorName)
	SetReg(REG_AUTHOR_NAME, szAuthorName)
}

/*-----------------------------------------------------------------------------
	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 InsertFunctionHeader()
{
	// 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()
	nLine = GetSymbolLine(szFunc)


	szMyName   = GetReg(REG_AUTHOR_NAME)
	szDate     = GetCurDate()

	InsBufLine(hbuf, nLine,      "  ")
	InsBufLine(hbuf, nLine + 1,  "/******************************************************************************")
	InsBufLine(hbuf, nLine + 2,  "  Function: @szFunc@")
	InsBufLine(hbuf, nLine + 3,  "  Description: ")
	InsBufLine(hbuf, nLine + 4,  "  INPUT: ")
	InsBufLine(hbuf, nLine + 5,  "  OUTPUT: ")
	InsBufLine(hbuf, nLine + 6,  "  Return: ")
	InsBufLine(hbuf, nLine + 7,  "  Revision: ")
	InsBufLine(hbuf, nLine + 8,  "         1. Author: @szMyName@")
	InsBufLine(hbuf, nLine + 9,  "            Date: @szDate@")
	InsBufLine(hbuf, nLine + 10, "            Changes: First create ")
	InsBufLine(hbuf, nLine + 11, " ******************************************************************************/")

	// put the insertion point inside the header comment
	SetBufIns(hbuf, nLine, 12)
}

macro InsertMaintenanceComment()
{
	// Get a handle to the current file buffer and the name
	// and location of the current symbol where the cursor is.
	hbuf = GetCurrentBuf()
	nLine = GetBufLnCur(hbuf)
	szCurLine = GetBufLine(hbuf, nLine)


	szMyName   = GetReg(REG_AUTHOR_NAME)
	szDate     = GetCurDate()

	if (IsBlankLine(szCurLine))
	{
		szBlank = szCurLine
	}
	else
	{
		szBlank = GetBlankString(szCurLine)
		InsBufLine(hbuf, nLine + 1,  szBlank)
		nLine = nLine + 1
	}


	InsBufLine(hbuf, nLine + 1,  "@szBlank@/*Sart:     ID: SVN: ,@szMyName@ @szDate@ */")
	InsBufLine(hbuf, nLine + 2,  szBlank)
	InsBufLine(hbuf, nLine + 3,  "@szBlank@/*End :     ID: SVN: ,@szMyName@ @szDate@ */")

}


/* 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()
{
	hbuf = GetCurrentBuf()

	szFilePath = GetBufName(hbuf)
	szFileName = GetFileNameFromPath(szFilePath)

	szMyName   = GetReg(REG_AUTHOR_NAME)
	szDate     = GetCurDate()

	InsBufLine(hbuf,  0, "  ")
	InsBufLine(hbuf,  1, "/******************************************************************************")
	InsBufLine(hbuf,  2, "  Copyright (c), 1991-2007, My Company.")
	InsBufLine(hbuf,  3, "  ")
	InsBufLine(hbuf,  4, "  File: @szFileName@")
	InsBufLine(hbuf,  5, "  Description: ")
	InsBufLine(hbuf,  6, "  Function List: //List main functions")
	InsBufLine(hbuf,  7, "  Revision:")
	InsBufLine(hbuf,  8, "         1. Author: @szMyName@")
	InsBufLine(hbuf,  9, "            Date: @szDate@")
	InsBufLine(hbuf, 10, "            Changes: First create file")
	InsBufLine(hbuf, 11, " ******************************************************************************/")

	return 12 /* line number of inserted */
}

macro NewHeaderFileStruct()
{

	hbuf = GetCurrentBuf()

	szFilePath = GetBufName(hbuf)
	szFileName = GetFileNameFromPath(szFilePath)

	szFileMainName = GetFileMainName(szFileName)
	szFileExtName  = GetFileExtName(szFileName)

	szFileMainName = toupper(szFileMainName)
	szFileExtName  = toupper(szFileExtName)


	InsBlankLine(hbuf,  0, 2)
	InsBufLine(hbuf,  0, "#endif /* __@szFileMainName@_@szFileExtName@__ */")
	InsBlankLine(hbuf,  0, 2)
	InsBufLine(hbuf,  0, " ******************************************************************************/")
	InsBufLine(hbuf,  0, " *                                 END                                        * ")
	InsBufLine(hbuf,  0, "/****************************************************************************** ")
	InsBlankLine(hbuf,  0, 10)
	InsBufLine(hbuf,  0, " ******************************************************************************/")
	InsBufLine(hbuf,  0, " *                               FUNCTION                                     * ")
	InsBufLine(hbuf,  0, "/****************************************************************************** ")
	InsBlankLine(hbuf,  0, 10)
	InsBufLine(hbuf,  0, " ******************************************************************************/")
	InsBufLine(hbuf,  0, " *                                STRUCT                                      * ")
	InsBufLine(hbuf,  0, "/****************************************************************************** ")
	InsBlankLine(hbuf,  0, 10)
	InsBufLine(hbuf,  0, " ******************************************************************************/")
	InsBufLine(hbuf,  0, " *                                 ENUM                                       * ")
	InsBufLine(hbuf,  0, "/****************************************************************************** ")
	InsBlankLine(hbuf,  0, 10)
	InsBufLine(hbuf,  0, " ******************************************************************************/")
	InsBufLine(hbuf,  0, " *                                 MACRO                                      * ")
	InsBufLine(hbuf,  0, "/****************************************************************************** ")

	InsBlankLine(hbuf,  0, 2)
	InsBufLine(hbuf,  0, "#define __@szFileMainName@_@szFileExtName@__")
	InsBufLine(hbuf,  0, "#ifndef __@szFileMainName@_@szFileExtName@__")

	InsBlankLine(hbuf,  0, 2)
	InsertFileHeader()
}


macro NewSrcFileStruct()
{

	hbuf = GetCurrentBuf()

	szFilePath = GetBufName(hbuf)
	szFileName = GetFileNameFromPath(szFilePath)

	szFileMainName = GetFileMainName(szFileName)
	szFileExtName  = GetFileExtName(szFileName)

	szFileMainName = toupper(szFileMainName)
	szFileExtName  = toupper(szFileExtName)


	InsBlankLine(hbuf,  0, 2)
	InsBufLine(hbuf,  0, " ******************************************************************************/")
	InsBufLine(hbuf,  0, " *                                 END                                        * ")
	InsBufLine(hbuf,  0, "/****************************************************************************** ")
	InsBlankLine(hbuf,  0, 10)
	InsBufLine(hbuf,  0, " ******************************************************************************/")
	InsBufLine(hbuf,  0, " *                               FUNCTION                                     * ")
	InsBufLine(hbuf,  0, "/****************************************************************************** ")
	InsBlankLine(hbuf,  0, 10)
	InsBufLine(hbuf,  0, " ******************************************************************************/")
	InsBufLine(hbuf,  0, " *                                GLOBAL                                      * ")
	InsBufLine(hbuf,  0, "/****************************************************************************** ")

	InsBlankLine(hbuf,  0, 4)
	InsertFileHeader()
}

macro GetCurDate()
{

	stCurTime  = GetSysTime(1)
	szDate     = cat(stCurTime.Year, "-")
	szDate     = cat(szDate, stCurTime.Month)
	szDate     = cat(szDate, "-")
	szDate     = cat(szDate, stCurTime.Day)
	return szDate

}


macro StrTrim(szSrc)
{
	szDst = StrTrimLeft(szSrc)
	szDst = StrTrimRight(szDst)

	return szDst
}

macro StrTrimLeft(szSrc)
{
	len = strlen(szSrc)
	i = 0
	while (i < len)
	{
		if (" " != szSrc[i] &&
		    "/t" != szSrc[i])
		{
			szDst = strmid(szSrc, i, len)
		    return szDst
		}
		i = i + 1
	}

	return ""
}

macro StrTrimRight(szSrc)
{
	len = strlen(szSrc)
	i = len - 1
	while (i >= 0)
	{
		if (" " != szSrc[i] &&
		    "/t" != szSrc[i])
		{
			szDst = strmid(szSrc, 0, i + 1)
		    return szDst
		}
		i = i - 1
	}

	return ""
}

macro GetFileNameFromPath(path)
{
	namelen = strlen(path)
	i = namelen
	while (i > 0)
	{
		if ("//" == path[i])
		{
			break;
		}
		i = i -1
	}
	if (i <= 0)
	{
		return path
	}
	j = namelen - i
	file = strmid(path, i + 1, namelen)
	return file
}

macro GetFileMainName(fileName)
{
	namelen = strlen(fileName)
	i = namelen
	while (i > 0)
	{
		if ("." == fileName[i])
		{
			break;
		}
		i = i -1
	}
	if (i <= 0)
	{
		return fileName
	}
	file = strmid(fileName, 0, i)
	return file
}

macro GetFileExtName(fileName)
{
	namelen = strlen(fileName)
	i = namelen
	while (i > 0)
	{
		if ("." == fileName[i])
		{
			break;
		}
		i = i -1
	}
	file = strmid(fileName, i + 1, namelen)
	return file
}

macro InsBlankLine(hbuf, startLine, lineCount)
{
	i = lineCount
	while (i > 0)
	{
		InsBufLine(hbuf,  startLine, "")
		i = i -1
	}
}


macro IsBlankLine(szLine)
{
	len = strlen(szLine)
	i = 0
	while (i < len)
	{
		if (" " != szLine[i] &&
		    "/t" != szLine[i])
		    return False
		i = i + 1
	}

	return True
}

macro GetBlankString(szLine)
{
	len = strlen(szLine)
	i = 0
	while (i < len)
	{
		if (" " != szLine[i] &&
		    "/t" != szLine[i])
		{
			szBlank = strmid(szLine, 0, i)
		    return szBlank
		}
		i = i + 1
	}

	return szLine
}






// 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

}

macro SuperBackspace()
{
    hwnd = GetCurrentWnd();
    hbuf = GetCurrentBuf();

    if (hbuf == 0)
        stop;   // empty buffer

    // get current cursor postion
    ipos = GetWndSelIchFirst(hwnd);

    // get current line number
    ln = GetBufLnCur(hbuf);

    if ((GetBufSelText(hbuf) != "") || (GetWndSelLnFirst(hwnd) != GetWndSelLnLast(hwnd))) {
        // sth. was selected, del selection
        SetBufSelText(hbuf, " ");  // stupid & buggy sourceinsight :(
        // del the " "
        SuperBackspace(1);
        stop;
    }

    // copy current line
    text = GetBufLine(hbuf, ln);

    // get string length
    len = strlen(text);

    // if the cursor is at the start of line, combine with prev line
    if (ipos == 0 || len == 0) {
        if (ln <= 0)
            stop;   // top of file
        ln = ln - 1;    // do not use "ln--" for compatibility with older versions
        prevline = GetBufLine(hbuf, ln);
        prevlen = strlen(prevline);
        // combine two lines
        text = cat(prevline, text);
        // del two lines
        DelBufLine(hbuf, ln);
        DelBufLine(hbuf, ln);
        // insert the combined one
        InsBufLine(hbuf, ln, text);
        // set the cursor position
        SetBufIns(hbuf, ln, prevlen);
        stop;
    }

    num = 1; // del one char
    if (ipos >= 1) {
        // process Chinese character
        i = ipos;
        count = 0;
        while (AsciiFromChar(text[i - 1]) >= 160) {
            i = i - 1;
            count = count + 1;
            if (i == 0)
                break;
        }
        if (count > 0) {
            // I think it might be a two-byte character
            num = 2;
            // This idiot does not support mod and bitwise operators
            if ((count / 2 * 2 != count) && (ipos < len))
                ipos = ipos + 1;    // adjust cursor position
        }
    }

    // keeping safe
    if (ipos - num < 0)
        num = ipos;

    // del char(s)
    text = cat(strmid(text, 0, ipos - num), strmid(text, ipos, len));
    DelBufLine(hbuf, ln);
    InsBufLine(hbuf, ln, text);
    SetBufIns(hbuf, ln, ipos - num);
    stop;
}

macro AddStruct()
{
	hbuf = GetCurrentBuf()
	ln = GetBufLnCur(hbuf)
	var szTypeName
	szTypeName = Ask("请输入结构名称:")
	szTypeName = toupper(szTypeName)

	InsBufLine(hbuf, ln, "typedef struct tag_@szTypeName@")
	ln = ln + 1
	InsBufLine(hbuf, ln, "{")
	ln = ln + 1
	InsBufLine(hbuf, ln, "    ")
	ln = ln + 1
	InsBufLine(hbuf, ln, "} @szTypeName@;")
	ln = ln + 1
}

/*=========================================================================*/
/*  Function: UniformCommentStyle                                          */
/*  Description: Change all // to /* */ 	 			                           */
/*=========================================================================*/
macro UniformCommentStyle()
{
    var hbuf
    hbuf = GetCurrentBuf ()  // current file

	var dwTotalLine
	dwTotalLine = GetBufLineCount(hbuf)

	var dwLine
	dwLine = 0
	while (dwLine < dwTotalLine)
	{
		var szLine
		szLine = GetBufLine(hbuf, dwLine)

		var nLineLen
		var nPos

		nLineLen = strlen(szLine)
		nPos = 0
		while (nPos < nLineLen)
		{
			if (nPos > 0)
			{
				if (szLine[nPos] == "/" && szLine[nPos - 1] == "/")
				{
					szLine[nPos] = "*"
					szLine = Cat(szLine, "*/")
					PutBufLine (hbuf, dwLine, szLine)
					break;
				}
			}
			nPos = nPos+1;
		}

		dwLine = dwLine + 1;
	}
}

/*=========================================================================*/
/*  Function: AddCodeGroup	                                               */
/*  Description: Add {} and auto indent                                    */
/*=========================================================================*/
macro AddCodeGroup()
{
	hbuf = GetCurrentBuf()
	ln = GetBufLnCur(hbuf) + 1
    szText = GetBufLine (hBuf, ln-1)

    nIndent = 0;
    nSpace  = 0;
    while (nIndent < strlen(szText))
    {
		if (szText[nIndent] == " ")
		{
		    nIndent = nIndent + 1;
		    nSpace  = nSpace + 1;
	    }
		else if (szText[nIndent] == "	")
		{
		    nIndent = nIndent + 1;
		    nSpace  = nSpace + 4;
	    }
		else
		    break;
    }
    szDate = GetCurDate()

	szSpace = ""
	nIndent = 0;
    while (nIndent < nSpace)
    {
		szSpace = Cat(szSpace, " ");
		nIndent = nIndent + 1;
    }


	szBrace = Cat(szSpace, "{");
	InsBufLine(hbuf, ln, szBrace)
	ln = ln + 1
	szBrace = Cat(szSpace, "    ");
	InsBufLine(hbuf, ln, szBrace)
	ln = ln + 1
	szBrace = Cat(szSpace, "}");
	InsBufLine(hbuf, ln, szBrace)
	ln = ln - 1;
	SetBufIns(hbuf, ln, nSpace + 4)


}



 

### SourceInsight 注释快捷键及其使用方法 在开发环境中,Source Insight 提供了一系列便捷的功能来帮助开发者高效完成编码工作。对于注释操作,虽然官方文档并未明确列出特定的快捷键组合[^1],但通过自定义配置文件或者工具栏选项可以实现单行或多行代码的快速注释。 以下是关于如何设置和使用注释快捷键的具体说明: #### 自定义注释快捷键 可以通过编辑 `keymap.ini` 文件来自定义快捷键绑定。例如,在该文件中添加如下内容即可指定新的注释快捷键: ```ini ; 单行注释快捷键 Command SingleComment = "Ctrl+/" ; 多行注释快捷键 Command MultiComment = "Ctrl+Shift+/" ``` 上述命令分别设置了单行注释为 `Ctrl+/` 和多行注释为 `Ctrl+Shift+/` 的快捷方式[^2]。 #### 默认注释行为 尽管未被显式提及于引用材料中,通常情况下,许多集成开发环境遵循通用标准——如 Visual Studio 或 Eclipse 所采用的方式处理注释逻辑。因此推测可能适用以下默认规则: - **单行注释**:选中文本后按下某个预设按键(比如 `Ctrl+/`),所选区域会被转换成以相应语言风格开头的形式(C++ 中为双斜杠 `//`)。 - **块状注释**:围绕选定范围自动插入起始符 (`/*`) 与结束符 (`*/`) 来包裹整个片段作为一大段备信息展示出来。 需要意的是实际效果取决于当前项目设定以及具体编程方言的支持情况;如果发现某些特性缺失,则需核查安装包完整性或是版本兼容性问题是否存在干扰因素影响正常运行状态表现形式差异较大时应重新审视基础架构搭建过程是否有误漏之处待完善优化调整直至满足预期目标为止。 ```python # Python 示例演示如何利用快捷键进行注释 def example_function(): result = calculate_something() # 假设这是需要加注释的一行代码 return result ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值