ミニマクロ 秀丸エディタ編
ミニマクロ
ページを作る程ではないけれど とても便利なマクロを集めてみました。
編集系
編集関連のマクロ
指定した文字列の個数を表示
##x = x; ##y = y; $str = input("何を数えてほしいの?", gettext(seltopx, seltopy, selendx, selendy)); disabledraw; gofiletop; searchdown2 $str, casesense; while (result) { ##i = ##i + 1; finddown; } moveto ##x, ##y; message str(##i) + "個あったわよ"; // ステータスバーに表示するなら↓こっち // title str(##i) + "個あったわよ", 1; // title -1, 1;
ファイル系
ファイル関連のマクロ
別名で保存しつつ 現ファイル名のまま編集を続けるマクロ
//snapshot.mac $fn = filename; SAVEAS; changename $fn; save;
削除系
削除関連のマクロ
行末ホワイトスペース削除
//DelLastSpace.mac disabledraw; #so = searchoption; $sb = searchbuffer; $rb = replacebuffer; #nowx = x; #nowy = y; replaceallfast "[ \t]+$","",regular; moveto #nowx, #nowy; setsearch $sb, #so; setreplace $rb; enabledraw; endmacro;
Backspace一回でホワイトスペースを一括削除
//DelSpaceAndTab.mac //Backspaceに割り当てる begingroupundo; disabledraw; backspace; while( 1 ) { left; if( code == 0x09 || code == 0x20 ) { delete; } else { if( x != 0 ) right; break; } } endgroupundo; enabledraw; endmacro;
検索系
検索関連のマクロ
カーソル上の単語を拾って、現在編集しているファイルを対象にGrep
// psearch.mac $searchbuffer = searchbuffer; #searchoption = searchoption; #lineno[-1] = lineno; #column[-1] = column; selectword; $word = gettext(seltopx, seltopy, selendx, selendy); gofiletop; searchdown2 $word, word; while (result && #i < 20) { $m[#i] = str(lineno) + ": " + gettext2(0, lineno, 40, lineno); #lineno[#i] = lineno; #column[#i] = column; #i = #i + 1; finddown; } movetolineno #column[-1] + 1, #lineno[-1]; menuarray $m, #i; if (result) movetolineno #column[result - 1] + 1, #lineno[result - 1]; setsearch $searchbuffer, #searchoption;
... disabledraw; gofiletop; ... enabledraw; menuarray $m, #i; でちらつかない。
if (result){ #r = result-1; disabledraw; movetolineno #column[#r] + 1, #lineno[#r]; enabledraw y - (windowheight/2); } だと、ジャンプ先を真ん中に表示する。
ウィンドウ系
ウィンドウ関連のマクロ
ウィンドウ分割をトグル切り替え
//windowsplit.mac #splitmodemax = 2; //旧型上下もトグルに含むなら3 弾くなら2 if (!splitmode) split #splitmodemax; else split splitmode-1; endmacro;
新規ファイルを新規ウィンドウで開く
//new_window.mac newfile; settabgroup 0,-1;
開きすぎてしまった実行結果を一括で閉じるマクロ
//close_exeresult.mac #c = hidemarucount; while( #i < #c ) { #handle = hidemaruhandle(0); if( filetype == "exeresult" ) #ft = 1; else #ft = 0; nexthidemaru; if( #ft ) closehidemaru #handle; #i = #i + 1; } endmacro;
表示系
表示関連のマクロ
折り返し表示をトグル
##o = getconfig("AutoAdjustOrikaeshi"); if (2 <= ##o) ##o = 0; else ##o = ##o+1; config "xAutoAdjustOrikaeshi:" + str(##o); // [固定幅]の時は(一時的な設定)じゃない本来の折り返し幅を読み込む // getconfig("Orikaeshi") / getconfig("w") / width は // [ウィンドウ幅] [最大]が選ばれた時点で値が変わってしまっているため if (0 == ##o) { if (!strlen(currentconfigset)) $$subkey = "Software\\Hidemaruo\\Hidemaru\\Default"; else $$subkey = "Software\\Hidemaruo\\Hidemaru\\Config\\"+currentconfigset; openreg "CURRENTUSER", $$subkey; ##w = getregnum("Orikaeshi"); closereg; config "w"+str(##w); } endmacro;
全角スペース表示のトグル
//半角にする場合は1を2 zをhに変更する事 if((getconfig("ShowBox") & 1) == 1){ config "z-"; }else{ config "z+"; } endmacro;
その他
その他のマクロ
選択範囲のURLをブラウザで一気に開くマクロ
if (selecting) { #endx = selendx; #endy = selendy; escape; movetolineno seltopcolumn + 1, seltoplineno; } searchdown2 "(?\\1)h?ttp(s?://[!#$%&*+,\\-./0-9:;=?@a-zA-Z^_|~]+)", regular; if (!#endy) { #endx = foundendx; #endy = foundendy; } while (result && (y < #endy || (y == #endy && x < #endx))) { openbyshell "http" + gettext(foundtopx, foundtopy, foundendx, foundendy); finddown; } escape; moveto #endx, #endy;
最終更新時間:2009年09月27日 11時18分09秒 [通知用URL]