Source Insight custom shortcut key, sourceinsight
I am always using Eclipse for development. If it is just java, this is enough, but from time to time I want to check the C/C ++ code, at this time, this tool is a little powerless, because there are a lot of C/C ++ code, usually put on the server, you have to look at it with Source Insight, Source Insight is very powerful, it can directly import the code on the server to the project, but it is a bit unaccustomed when it is used. It is not as convenient as Eclipse, especially in terms of shortcuts, source Insight is much better than Eclipse. I think it is like Photoshop and meitu xiuxiu. Here we will introduce how to modify the comment shortcut key of Source Insight.
There are two types of Annotations:
// The line comment shortcut in Eclipse is: Ctrl +/
/* Paragraph comments */The shortcut key in Eclipse is: Ctrl + Shift +/
I believe that when you use Source Insight to view the code, you should program it. Then, to add a comment in Source Insight, you need to write the code. Its syntax is similar to that in C language, and there are many built-in functions, you only need to call it. We recommend that you read Help first. The detailed function description is provided here.
In fact, the shortcut keys in Source Insight correspond to a piece of macro code.
D: \ user directory \ Documents ents \ Source Insight \ Projects \ Base \ utils. em
In this file, of course, this directory may be different from yours, but you can find it like this:
Progect-> Open progect-> Base
After the Base is installed, a project will be created and its path will be displayed.
Utils. em contains a bunch of macro code.
You can open it with any text editor,
Add a macro:
This code is // line comment
The function is to Add/Remove line comments to/from selected rows.
// Add comments macro MultiLineComment () {hwnd = GetCurrentWnd () selection = GetWndSel (hwnd) LnFirst = GetWndSelLnFirst (hwnd) // retrieve the first line number LnLast = GetWndSelLnLast (hwnd) // obtain the row number 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) // obtain the row if (buf = "") {// skip the empty row Ln = Ln + 1 cont Inue} if (StrMid (buf, 0, 1) = "/") {// you need to cancel the annotation to prevent line if (StrMid (buf, 1, 2) = "/") {PutBufLine (hbuf, Ln, StrMid (buf, 2, Strlen (buf)} if (StrMid (buf, 0, 1 )! = "/") {// Note PutBufLine (hbuf, Ln, Cat ("//", buf)} Ln = Ln + 1} SetWndSel (hwnd, selection )}Added and saved! Add another shortcut key for this macro: Ctrl +/
Method:
Options-> Key Assignments
A dialog box is displayed. In the input box below the Command box, enter the saved macro name MultiLineComment (do not copy it. It is best to manually enter it)
In fact, as long as you enter the first few characters, the selection box below will filter out other macro names, select the macro to add the shortcut key, if no shortcut key is added, there is no Key name under Keystrokes. Click Assign New Key ..., A dialog box is displayed,
Press the key-combination you want to assign, or click a mouse .....
The general meaning is to press the combination key or click the mouse, it is best not to press the mouse, you can use Ctrl Alt Shift combination, press what we mean, just press Ctrl +, ctrl +/appears under Keystrokes. If there are duplicates, a prompt is displayed,
Do you want to remove that keystroke from the "XXXXXXX" command?
If you want to use this shortcut key as the front macro, click yes. You can try another one.
Add/* Paragraph comments */
// Comment the selected row/**/macro CommentSelStr () {hwnd = GetCurrentWnd () // sel = GetWndSel (hwnd) lnFirst = GetWndSelLnFirst (hwnd) lnLast = GetWndSelLnLast (hwnd) hbuf = GetCurrentBuf () Ln = Lnfirst <span style = "white-space: pre"> </span> buf = GetBufLine (hbuf, Ln) // msg (buf) if (buff = "" | Strlen (buf) = 0) {// msg ("buf is null")} else {if (StrMid (buf, 0, 1) = "/") {// you need to cancel comments to prevent line if (StrMid (buf, 1, 2) = "*") with only one character "*") {PutBufLine (hbuf, Ln, StrMid (buf, 2, Strlen (buf)} else {str = cat ("/*", buf) PutBufLine (hbuf, ln, str) }} else {str = cat ("/*", buf) PutBufLine (hbuf, ln, str)} ln = lnLastbuf = GetBufLine (hbuf, Ln) len_s = strlen (buf) // msg (len_s) // msg (buf) // msg (StrMid (buf, strlen (buf)-1, strlen (buf ))) // msg (StrMid (buf, strlen (buf)-2, strlen (buf)-1) if (StrMid (buf, strlen (buf)-1, strlen (buf) = "/") {if (StrMid (buf, strlen (buf)-2, strlen (buf)-1) = "*") {PutBufLine (hbuf, Ln, StrMid (buf, 0, Strlen (buf)-2)} else {str = cat (buf, "*/") PutBufLine (hbuf, ln, str)} else {str = cat (buf, "*/") PutBufLine (hbuf, ln, str)} // SetWndSel (hwnd, sel )}}
Add the shortcut key: Ctrl + Shift +/, as described above
The following are some commonly used macros. The shortcut keys are recommended:
Addm1_comment: Ctrl + Shift + 3
// Add "# ifdef 0" and "# endif" macro addm1_comment () {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)} // comments macro CommentSingleLine () {hbuf = GetCurrentBuf () ln = GetBufLnCur (hbuf) str = GetBufLine (hbuf, ln) str = cat ("/*", str) str = cat (str, "*/") PutBufLine (hbuf, ln, str )}
Note: The paragraph comments are written by myself. Others are copied over the network. The functions involved here are simple,