source insight中的块注释

本文介绍了如何在source Insight中自定义宏实现块注释功能,偏好使用""注释方式。通过编辑Utils.em文件添加宏代码,然后在"选项->菜单关联"中启用并分配快捷键,即可方便地进行代码块注释和取消注释。
摘要由CSDN通过智能技术生成

用了许久source Insight写C/C++代码,发现其中没有块注释功能很不方便,于是今天研究了下怎样让sourceInsight实现块注释。

网上介绍了很多方法实现块注释,但是都是对代码利用“//”逐行注释,没有用“”实现的,我个人比较倾向于用注释代码块,所以今天自己动手写了利用”“实现块注释代码。

好了,废话不多说,直接上宏代码,后面会介绍使用方法:

  1. macro _tsGetTabSize()  
  2.  
  3.     szTabSize GetReg("TabSize");  
  4.   
  5.     if (szTabSize != "")  
  6.      
  7.         tabSize AsciiFromChar(szTabSize[0]) AsciiFromChar("0");  
  8.      
  9.     else  
  10.      
  11.         tabSize 4;  
  12.      
  13.   
  14.     return tabSize;  
  15.  
  16.   
  17.   
  18. macro CommentBlock_Joyce()  
  19.  
  20.     hbuf GetCurrentBuf();  
  21.     hwnd GetCurrentWnd();  
  22.   
  23.     sel GetWndSel(hwnd);  
  24.   
  25.     iLine sel.lnFirst;  
  26.       
  27.     // indicate the comment char according to the file type  
  28.     // for example, using "#" for perl file(.pl) and "" for C/C++.  
  29.     filename tolower(GetBufName(hbuf));  
  30.     suffix "";  
  31.     len strlen(filename);  
  32.     len 1;  
  33.     while (i >= 0)  
  34.      
  35.         if (filename[i-1] == ".")  
  36.          
  37.             suffix strmid(filename, i, len)  
  38.             break;  
  39.          
  40.         -1;  
  41.      
  42.     if  suffix == "pl"  
  43.      
  44.         filetype 2; // PERL  
  45.      
  46.     else  
  47.      
  48.         filetype 1; //  
  49.      
  50.   
  51.     szLine GetBufLine(hbuf, iLine);  
  52.     if (filetype == 1)  //  
  53.      
  54.         szLine cat("    ");  
  55.      
  56.     else                // PERL  
  57.      
  58.         szLine cat("# ", szLine);  
  59.      
  60.     PutBufLine(hbuf, iLine, szLine);  
  61.   
  62.   
  63.   
  64.     if (sel.lnFirst == sel.lnLast)  
  65.      
  66.         tabSize _tsGetTabSize() 1;  
  67.         sel.ichFirst sel.ichFirst tabSize;  
  68.         sel.ichLim sel.ichLim tabSize;  
  69.      
  70.     SetWndSel(hwnd, sel);  
  71.  
  72.   
  73.   
  74.   
  75.   
  76. //  
  77. // Undo the CommentBlock for the selected text.  
  78. //  
  79. macro UnCommentBlock_Joyce()  
  80.  
  81.     hbuf GetCurrentBuf();  
  82.     hwnd GetCurrentWnd();  
  83.       
  84.     sel GetWndSel(hwnd);  
  85.   
  86.     iLine sel.lnFirst;  
  87.   
  88.   
  89.     // indicate the comment char according to the file type  
  90.     // for example, using "#" for perl file(.pl) and "" for C/C++.  
  91.     filename tolower(GetBufName(hbuf));  
  92.     suffix "";  
  93.     len strlen(filename);  
  94.     len 1;  
  95.     while (i >= 0)  
  96.      
  97.         if (filename[i-1] == ".")  
  98.          
  99.             suffix strmid(filename, i, len)  
  100.             break;  
  101.          
  102.         -1;  
  103.      
  104.     if  suffix == "pl"  
  105.      
  106.         filetype 2; // PERL  
  107.      
  108.     else  
  109.      
  110.         filetype 1; //  
  111.      
  112.   
  113.     tabSize 0;  
  114.   
  115.     endLine GetBufLine(hbuf, sel.lnLast);  
  116.     endLineLen strlen(endLine);  
  117.     szLine GetBufLine(hbuf, iLine);  
  118.     len strlen(szLine);  
  119.     szNewLine "";  
  120.     commentState 1;  
  121.   
  122.     if (szLine[0] == "/" && szLine[1] == "*")  
  123.      
  124.         if(endLine[endLineLen-2] == "/" && endLine[endLineLen-3] == "*")  
  125.          
  126.             if (filetype == 1)  //  
  127.              
  128.                 if (len 1)  
  129.                  
  130.                     if (szLine[0] == "/" && szLine[1] == "*")  
  131.                      
  132.                         if (len 2)  
  133.                      
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值