7
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

sakuraエディタマクロ

7
Posted at

最近はまったく使わないけれど今までに作ったマクロをいくつか。

マクロの追加方法

  1. 設定>共通設定
  2. マクロタブを選択
  3. [参照]をクリックしてマクロファイルを選択
  4. 名前とIdを入力(選択)して[設定]をクリック
  5. カスタムメニュータブの種別に「外部マクロ」を選択してショートカットを設定。

終了タグを挿入する

addEndTag.js

   var regExpObj     = new RegExp('<(\\w+)>');
   var currentLine   = "";
   var currentTagStr = "";
   
   var wshObj = new ActiveXObject("WScript.Shell");
   var resArray = Array;
   
   currentLine = GetLineStr(0);
   
   if (resArray = regExpObj.exec(currentLine) != null) {
         GoLineEnd();
         InsText("</"+RegExp.$1+">");
   }

指定文字列ごとに上下移動する

ソースを見る際に、指定文字列(ここではpublic/private/protected)ごとに上下移動する。
※Visual Basic EditorなどでCtrl+↑↓で関数ごとに移動する動作のような感じ。
※他に移動単位としたい文字列があれば随時パターンを編集("function"など)
※大文字小文字は区別しない

moveDownEveryDefine.js

 ------------------------------------------------
 // 定義ごとにカーソルを移動する
 // ※Public/Private/Protectedが行頭にある場所ごとに下に移動するだけ
 
 var regExpObj     = new RegExp('Public|Private|Protected', "i");
 var currentLine   = "";
 
 var resArray = Array;
 
 currentLine = GetLineStr(0);
 
 if (regExpObj.exec(currentLine) != null) {
     Down();
 }
 
 while (regExpObj.exec(currentLine) == null && currentLine != "") {
     Down();
     currentLine = GetLineStr(0);
 }
 ------------------------------------------------

moveUpEveryDefine.js

 ------------------------------------------------
 // 定義ごとにカーソルを移動する
 // ※Public/Private/Protectedが行頭にある場所ごとに上に移動するだけ
 
 var regExpObj     = new RegExp('Public|Private|Protected', "i");
 var currentLine   = "";
 var searchCnt     = 1000;
 
 var resArray = Array;
 
 currentLine = GetLineStr(0);
 
 if (regExpObj.exec(currentLine) != null) {
     Up();
     searchCnt--;
 }
 
 // 不明(先頭行に達したことを判定する方法)
 while (regExpObj.exec(currentLine) == null && searchCnt > 0) {
     Up();
     searchCnt--;
     currentLine = GetLineStr(0);
 }
 ------------------------------------------------

選択文字をで囲む

addSpanTag.js

 selStr = GetSelectedString();
 InsText('<span style="font-size:x-small;">'+ selStr +'</span>');
7
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?