LoginSignup
7
7

More than 5 years have passed since last update.

SublimeText | 秀丸の5行移動機能をマクロで実現する

Last updated at Posted at 2014-06-11

SublimeText | 秀丸の5行移動機能をマクロで実現する

概要

秀丸では

  • Ctrl+上下キーで上下に5行移動できます。
  • Ctrl+Shift+上下キーで上下に5行移動しつつ範囲選択できます。

SublimeTextの前は秀丸を使っていたこともあり、
この機能がすっかり手になじんでいるため、SublimeTextに移植してみました。

マクロ保存機能を活用

以下の手順でマクロを保存します

  1. マクロの記録開始(Ctrl+Q)
  2. 5行下に移動 / 5行上に移動 / Shiftを押しながら5行下に移動 / Shiftを押しながら5行上に移動
  3. マクロの記録終了(Ctrl+Q)
  4. マクロの保存(Tools => Save Macro)
  5. マクロのキー割り当て

上移動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行固定の機能のみ作成しました。

7
7
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
7