Use of the source insight macro and custom shortcuts

Source: Internet
Author: User

I believe that anyone who has read large source code knows source insight.

Today, I spent some time organizing two macros and using the shortcut key to generate code comments. Very convenient.

Go to the topic!

 

① Open source insight> Project> open project> base> OK

② Open the utils. Em macro file

③ Add the following macros (similar to C functions)

 

// Multi-line code comment macro multilinecomment () {hwnd = getcurrentwnd () // obtain the text window selection = getwndsel (hwnd) // obtain the selected object lnfirst = getwndsellnfirst (hwnd) // obtain the first line number lnlast = getwndsellnlast (hwnd) // obtain the last line number hbuf = getcurrentbuf () // obtain the current window text Ln = lnfirst while (LN <= lnlast) {// retrieve the row Buf = getbufline (hbuf, LN) corresponding to ln // skip the empty row if (BUF = "") {Ln = ln + 1 continue} // If commented out, uncomment if (strmid (BUF, 0, 1) = "/") {If (strmid (BUF, 1, 2) = "/" ) {Putbufline (hbuf, LN, strmid (BUF, 2, strlen (BUF) // adjust the cursor position selection. ichfirst = selection. ichfirst-2; selection. ichlim = selection. ichlim-2 ;}} if (strmid (BUF, 0, 1 )! = "/") {// Add comments putbufline (hbuf, LN, CAT ("//", Buf) // adjust the cursor position selection. ichfirst = selection. ichfirst + 2; selection. ichlim = selection. ichlim + 2;} ln = ln + 1} // the final result is setwndsel (hwnd, selection )}

// Generate a single row comment macro singlelinecomment () {hwnd = getcurrentwnd () // obtain the text window selection = getwndsel (hwnd) // obtain the selected object lnfirst = getwndsellnfirst (hwnd) // obtain the row number hbuf = getcurrentbuf () // obtain the current window text // obtain the current time sztime = getpolicime (1) hour = sztime. hourminute = sztime. minutesecond = sztime. secondday = sztime. daymonth = sztime. monthYear = sztime. yearif (day <10) szday = "0 @ day @" elseszday = dayif (month <10) szmonth = "0 @ month @" elseszmonth = month // name szmyname = "yarkey" Buf = getbufline (hbuf, lnfirst) // yarkey @ 20130321 remark: commentadd = "// @ szmyname \@year @ szmonth @ szday @ remark:" commentaddlen = strlen (commentadd) putbufline (hbuf, lnfirst, CAT (BUF, commentadd) selection. ichfirst = selection. ichfirst + commentaddlen; selection. ichlim = selection. ichlim + commentaddlen; setwndsel (hwnd, selection )}

④ After adding the file, press Ctrl + S to save the file.

⑤ Open your project> Option> key assignments to find:

MACRO: multilinecomment

MACRO: singlelinecomment

6. Click assign new key...

Now, set the shortcut keys you are used! ^

It can be a combination of ALT, Ctrl, and so on.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.