2008/03/15

EmEditorのマクロ 選択範囲へ改行タグ

EmEditorのマクロ機能で、選択範囲に改行タグを入れるマクロをVBSで書いてみました。上から選択しても下から選択しても動くように、カレントポジジョンを見て判定。

うーん、「選択範囲」をどう捉えるかちょっと悩みつつ、ひとまず自分が使いやすいように。

  1. Dim intXB        '選択範囲の最終行のX  
  2. Dim intYC        '現在位置のY  
  3. Dim intYA        '選択範囲の開始行  
  4. Dim intYB        '選択範囲の最終行  
  5. Dim i  
  6.   
  7. intYC = document.selection.GetActivePointY( eePosLogical )  
  8. intXB = document.selection.GetBottomPointX( eePosLogical )  
  9.   
  10. intYA = document.selection.GetAnchorPointY( eePosLogical )  
  11. intYB = document.selection.GetBottomPointY( eePosLogical )  
  12.   
  13.   
  14. If intXB = 1 Then   
  15.     intYB = intYB -1  
  16.     If intYC > 1 Then intYC = intYC - 1  
  17. End If  
  18.   
  19. If intYC <> intYB Then  
  20.     For i = intYC To intYB  
  21.         document.selection.StartOfLine False,eeLineLogical  
  22.         document.selection.EndOfLine False,eeLineLogical  
  23.         document.selection.Text="<br />"  
  24.         document.selection.LineDown  
  25.     Next  
  26. Else  
  27.     For i= intYA to intYB  
  28.         document.selection.StartOfLine False,eeLineLogical  
  29.         document.selection.EndOfLine False,eeLineLogical  
  30.         document.selection.Text="<br />"  
  31.         document.selection.LineDown  
  32.     Next  
  33. End If  

0 件のコメント: