Macro/投稿/204

http://sakura.qp.land.to/?Macro%2F%C5%EA%B9%C6%2F204


Top > Macro > 投稿 > 204

行頭/行末に移動(改行単位)

  • ページ: Macro/投稿
  • 作者: ryoji
  • カテゴリー: js
  • 投稿日: 2009-06-16 (火) 22:57:01

メッセージ

キーに割り当てるとすれば Alt+Home, Alt+Shift+Home, Alt+End, Alt+Shift+End あたりにするのがいいでしょうかね。

  0
  1
  2
// GoLogicalLineTop.js
// 行頭に移動(改行単位)
Editor.GoLineTop(9);
  0
  1
  2
// GoLogicalLineTop_Sel.js
// (選択)行頭に移動(改行単位)
Editor.GoLineTop(13);
  0
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
// GoLogicalLineEnd.js
// 行末に移動(改行単位)
var i = Number(Editor.ExpandParameter("$y"));
var str = Editor.GetLineStr(0);
if (str.length)
{
    var c = str.substr(str.length - 1);
    if (c == "\r" || c == "\n")
    {
        do
        {
            Editor.down();
        } while(i == Number(Editor.ExpandParameter("$y")))
        Editor.up();
        Editor.GoLineEnd();
    }
    else
    {
        Editor.GoFileEnd();
    }
}
  0
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
// GoLogicalLineEnd_Sel.js
// (選択)行末に移動(改行単位)
var i = Number(Editor.ExpandParameter("$y"));
var str = Editor.GetLineStr(0);
if (str.length)
{
    var c = str.substr(str.length - 1);
    if (c == "\r" || c == "\n")
    {
        do
        {
            Editor.down_Sel();
        } while(i == Number(Editor.ExpandParameter("$y")))
        Editor.up_Sel();
        Editor.GoLineEnd_Sel();
    }
    else
    {
        Editor.GoFileEnd_Sel();
    }
}

「行末に移動」はJump()マクロを使えばもう少し簡潔に書けるけどスクロールが目立つ場合があるので、上記の方法にしてスクロールを抑えています。



URL B I U SIZE Black Maroon Green Olive Navy Purple Teal Gray Silver Red Lime Yellow Blue Fuchsia Aqua White

リロード   新規 編集 凍結 差分 添付 複製 名前変更   ホーム 一覧 単語検索 最終更新 バックアップ リンク元   ヘルプ   最終更新のRSS
Last-modified: 2009-06-18 (木) 01:31:59 (5398d)