LoginSignup
2
3

More than 5 years have passed since last update.

Autometerで選択文字列を置換:AppleScript版

Last updated at Posted at 2015-02-13

応用例:"x"という文字列を選択してCmd+kを押すと"\mathbf{x}"にしたい.

Autometerで作成

  • 新規作成でサービスを作る
  • 「AppleScriptを実行」をつかう
    • 「選択されたテキストを出力で置き換える」をチェック
    • 「次の選択項目を受け取る」は「テキスト」
  • 中身はこれ.
表示するだけ
on run argv

    set output to ("\\mathbf{" & (item 1 of argv) & "}")

end run
  • "to_mathbf"という名前で保存する.多分保存先は自動的に/User/yourname/Library/Services/以下.

次は「システム環境設定」

  • 「キーボード」の「ショートカット」を開く.
  • 「サービス」のどこかにto_mathbfがあるので探す.
  • それにショートカットキーを割り当てる.たとえばCmd+Kに.

では実行

何かでテキストを選択したままCmd+Kを押すと,実行される.

実行されない場合にはそのソフトを再起動してみる.

ToDo

もっと高速化したい.1秒ぐらい.AppleScript版でも意外に遅かった.

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