Automatically add or remove C comments using the source insight macro

Source: Internet
Author: User

Our project is mainly developed for the storage C in Linux, and the SI tool is undoubtedly necessary. However, it is inconvenient to manually add comments. On the internet, there are all c ++ comments. I wrote a c file myself and shared it. If you are interested, modify it.

 

 

/* <Br/> the info like: <br/> by guixue 2009-8-19 <br/> */<br/> macro getcommentinfo () <br/> {<br/> szmyname = "guixue" <br/> hbuf = getcurrentbuf () <br/> Ln = getbuflncur (hbuf) <br/> sztime = getpolicime (1) <br/> hour = sztime. hour <br/> minute = sztime. minute <br/> second = sztime. second <br/> day = sztime. day <br/> month = sztime. month <br/> year = sztime. year <br/> If (day <10) <br/> szday = "0 @ day @" <br/> else <br/> szday = day <br/> If (month <10) <br/> szmonth = "0 @ month @" <br/> else <br/> szmonth = month </P> <p> szdescription = "by" <br/> szinfo = "@ szdescription @ szmyname @ year @-@ szmonth @-@ szday @" <br/> return szinfo <br/>}< br/> macro singlelinecomment () <br/>{< br/> hbuf = getcurrentbuf () <br/> Ln = getbuflncur (hbuf) <br/> szinfo = getcommentinfo () <br/> insbufline (hbuf, LN + 1, "/* @ szinfo @ */") <br/>}< br/> macro c_commentblock () <br/>{< br/> hbuf = getcurrentbuf (); <br/> hwnd = getcurrentwnd (); <br/> sel = getwndsel (hwnd ); <br/>/* <br/> szline = getbufline (hbuf, Sel. lnfirst); <br/> szline = CAT ("/*", szline); <br/> putbufline (hbuf, Sel. lnfirst, szline); <br/> */<br/> szinfo = getcommentinfo () <br/> szinfo = "/* @ szinfo @" <br/> insbufline (hbuf, Sel. lnfirst, szinfo) <br/> insbufline (hbuf, Sel. lnlast + 2, "*/") <br/> tabsize = 4; <br/> SEL. ichfirst = SEL. ichfirst + tabsize; <br/> SEL. ichlim = SEL. ichlim + tabsize; <br/> setwndsel (hwnd, Sel); <br/>}< br/> macro c_uncommentblock () <br/>{< br/> hbuf = getcurrentbuf (); <br/> hwnd = getcurrentwnd (); <br/> sel = getwndsel (hwnd ); <br/> iline = SEL. lnfirst; <br/> szline = getbufline (hbuf, iline); <br/> szinfo = getcommentinfo () <br/> szinfo = "/* @ szinfo @" </P> <p> If (szline [0] = "/" & szline [1] =" *") <br/>{< br/> If (szinfo = szline) <br/>{< br/> delbufline (hbuf, iline) <br/>}< br/> else <br/>{< br/> return false; <br/>}< br/> else <br/>{< br/> return false; <br/>}< br/> iline = SEL. lnLast-1; <br/> szline = getbufline (hbuf, iline); <br/> Len = strlen (szline) <br/> If (LEN <2) <br/> return false; <br/> If (szline = "*/") <br/> {<br/> delbufline (hbuf, iline) <br/>}< br/> else <br/>{< br/> return false; <br/>}< br/> setwndsel (hwnd, Sel ); <br/> return true; <br/>}< br/> macro c_do_comment () <br/>{< br/> flag = c_uncommentblock () <br/> If (flag = false) <br/>{< br/> c_commentblock () <br/>}< br/>

 

Add method:

Usage instructions:

1.
Project-> open project...
Open the base project (usually in "My Documents/source
Insight/projects/base );
2.
Project-> add and remove project files...
Add macro files (you can also add code to existing files, such as utils. Em files );
3.
Options-> menu assignments: Open the menu assignments window,
Input macro in command and select the macro to use,
Add to the appropriate menu.

You can also customize shortcuts;

 

Si official macro library: http://www.sourceinsight.com/public/macros/

Common macros of source insight

 

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.