|
自分は以下のマクロを使っています。
範囲選択が1行内であればその文字列を検索に取り込みます。
2行以上の場合はその選択範囲を検索置換対象にします。
#save_x = x;
#save_y = y;
$save_buf = searchbuffer;
#save_sel = selecting;
if (#save_sel && seltopy == selendy) {
$sel1 = gettext(seltopx, seltopy, selendx, selendy);
} else {
$sel1 = $save_buf;
}
$srch1 = input("検索文字列", $sel1);
#ret = result;
if (#ret == 0 || $srch1 == "") endmacro;
while (1) {
$rep1 = input("置換文字列", $srch1);
#ret = result;
if (#ret == 0) endmacro;
if ($rep1 != $srch1) break;
}
menu "単純置換", "単語置換", "正規表現";
#mode = result;
if (#mode == 0) endmacro;
disabledraw;
goscreentop;
#screentop_y = y;
moveto #save_x, #save_y;
if (#save_sel && seltopy != selendy) {
if (#mode == 1) {
replaceallfast $srch1, $rep1, casesense, inselect;
#ret1 = result;
} else if (#mode == 2) {
replaceallfast $srch1, $rep1, word, casesense, inselect;
#ret1 = result;
} else if (#mode == 3) {
replaceallfast $srch1, $rep1, regular, inselect;
#ret1 = result;
}
escapeinselect;
} else {
if (#mode == 1) {
replaceallfast $srch1, $rep1, casesense;
#ret1 = result;
} else if (#mode == 2) {
replaceallfast $srch1, $rep1, word, casesense;
#ret1 = result;
} else if (#mode == 3) {
replaceallfast $srch1, $rep1, regular;
#ret1 = result;
}
}
moveto #save_x, #save_y;
enabledraw #screentop_y;
message str(#ret1) + "個置換しました。";
|
|