0

私の最終的な目的は、Alt + Enterキーを押すと、自動的に箇条書きをインテリジェントに挿入するAppleScriptを作成することです。私はBBEditでこれを行おうとしています。これが、BBEditフォーラムから入手したAppleスクリプトです。

tell application "BBEdit"
    try
        tell text of front text window
            set lineOfInsertionPoint to line (startLine of selection)
            set findReco to find "^\\s*\\d+\\." searching in lineOfInsertionPoint options {search mode:grep}
            if found of findReco = true then
                set leadingNumber to text 1 thru -2 of (found text of findReco)
                set text of selection to return & (leadingNumber + 1) & ". "
                select insertion point after selection
            else if found of findReco = false then
                set findReco to find "^\\s*\\* " searching in lineOfInsertionPoint options {search mode:grep}
                if found of findReco = true then
                    set text of selection to return & "* "
                    select insertion point after selection
                else
                    set findReco to find "^\\s*\\+" searching in lineOfInsertionPoint options {search mode:grep}
                    if found of findReco = true then

                        set text of selection to return & tab & "+ "
                        select insertion point after selection
                    end if
                end if
            end if
        end tell
    on error errMsg number errNum
        set sep to "=============================="
        set e to sep & return & "Error: " & errMsg & return & sep & return ¬
            & "Error Number: " & errNum & return & sep
        beep
        display dialog e
    end try
end tell

スクリプトはうまく機能しますが、問題は、最初に特定の数のタブストップまたは空白がある場合、AppleScriptは空白/タブストップを無視して行の先頭に次の箇条書きを挿入することです。

だから私の実際の質問は、「Applescriptを介して先頭のタブストップまたは空白の数をどのように取得するのか」ということであり、それをここに連結しますか?

乾杯。

4

1 に答える 1

1

Kendall Conradは、同様のより機能的なスクリプトをhttp://www.angelwatt.com/words/2011/04/11/bbedit-smart-newline-open-line/で更新しました。

于 2012-03-30T10:53:27.377 に答える