SublimeText | 秀丸の5行移動機能をマクロで実現する
概要
秀丸では
- Ctrl+上下キーで上下に5行移動できます。
- Ctrl+Shift+上下キーで上下に5行移動しつつ範囲選択できます。
SublimeTextの前は秀丸を使っていたこともあり、
この機能がすっかり手になじんでいるため、SublimeTextに移植してみました。
マクロ保存機能を活用
以下の手順でマクロを保存します
- マクロの記録開始(Ctrl+Q)
- 5行下に移動 / 5行上に移動 / Shiftを押しながら5行下に移動 / Shiftを押しながら5行上に移動
- マクロの記録終了(Ctrl+Q)
- マクロの保存(Tools => Save Macro)
- マクロのキー割り当て
上移動5、下移動5、上選択移動5、下選択移動5の回数分実施します。
内容に合わせて手順2を選択。
出来上がったマクロ
下移動5、下選択移動5を例示します。
下5移動のマクロ
[
{
"args":
{
"by": "lines",
"forward": true
},
"command": "move"
},
{
"args":
{
"by": "lines",
"forward": true
},
"command": "move"
},
{
"args":
{
"by": "lines",
"forward": true
},
"command": "move"
},
{
"args":
{
"by": "lines",
"forward": true
},
"command": "move"
},
{
"args":
{
"by": "lines",
"forward": true
},
"command": "move"
}
]
下5選択移動のマクロ
[
{
"args":
{
"by": "lines",
"extend": true,
"forward": true
},
"command": "move"
},
{
"args":
{
"by": "lines",
"extend": true,
"forward": true
},
"command": "move"
},
{
"args":
{
"by": "lines",
"extend": true,
"forward": true
},
"command": "move"
},
{
"args":
{
"by": "lines",
"extend": true,
"forward": true
},
"command": "move"
},
{
"args":
{
"by": "lines",
"extend": true,
"forward": true
},
"command": "move"
}
]
補足
移動行数に拡張性を持たせたい場合は Python を利用した Plugin として実装したほうが良いですね。
私が欲しかったのは秀丸の5行移動だったので5行固定の機能のみ作成しました。