
この Sublime Text だが、デフォルトではプリント機能がない。どうするかというと、標準のプラグイン「Print to HTML」を使い、一旦ブラウザに出力してから、ブラウザの機能でプリントするのだそうだ。
ところがこれを使ってもブラウザに出力されない。Print to HTMLのソースを見ると、
def send_to_browser(html): """Create a temp file containing html and open it in the default web browser.""" tmp_html = tempfile.NamedTemporaryFile(delete=False, suffix='.html') tmp_html.write(html) tmp_html.close() desktop.open(tmp_html.name)
なにやらテンポラリファイルを作っている。さてはと OS の環境変数を見たら、TMP
と TEMP
が作られていなかった。こいつらを適切に設定し、Sublimeを再実行したところ、ちゃんと出力されるようになった。
Default (OSX).sublime-keymap
Sublime をダイヤモンドカーソル風にする定義ファイル。完全互換ではない。
/* diamond cursol definition * created by: azira@usagi-goten.com */ [ { "keys": ["ctrl+d"], "command": "move", "args": {"by": "characters", "forward": true} }, { "keys": ["ctrl+s"], "command": "move", "args": {"by": "characters", "forward": false} }, { "keys": ["ctrl+e"], "command": "move", "args": {"by": "lines", "forward": false} }, { "keys": ["ctrl+x"], "command": "move", "args": {"by": "lines", "forward": true} }, { "keys": ["ctrl+a"], "command": "move", "args": {"by": "subwords", "forward": false} }, { "keys": ["ctrl+f"], "command": "move", "args": {"by": "subwords", "forward": true} }, { "keys": ["ctrl+r"], "command": "move", "args": {"by": "pages", "forward": false} }, { "keys": ["ctrl+c"], "command": "move", "args": {"by": "pages", "forward": true} }, { "keys": ["ctrl+t"], "command": "delete_word", "args": { "forward": true, "sub_words": true } }, { "keys": ["ctrl+g"], "command": "right_delete" }, { "keys": ["ctrl+y"], "command": "cut" }, { "keys": ["ctrl+j"], "command": "show_overlay", "args": {"overlay": "goto", "text": ":"} }, { "keys": ["ctrl+shift+e"], "command": "select_lines", "args": {"forward": false} }, { "keys": ["ctrl+shift+x"], "command": "select_lines", "args": {"forward": true} }, { "keys": ["ctrl+q", "ctrl+d"], "command": "move_to", "args": {"to": "eol"} }, { "keys": ["ctrl+q", "ctrl+s"], "command": "move_to", "args": {"to": "bol"} }, { "keys": ["ctrl+q", "ctrl+r"], "command": "move_to", "args": {"to": "bof"} }, { "keys": ["ctrl+q", "ctrl+c"], "command": "move_to", "args": {"to": "eof"} }, { "keys": ["ctrl+q", "ctrl+e"], "command": "move", "args": {"by": "pages", "forward": false} }, { "keys": ["ctrl+q", "ctrl+x"], "command": "move", "args": {"by": "pages", "forward": true} }, { "keys": ["ctrl+q", "ctrl+f"], "command": "show_panel", "args": {"panel": "find"} }, { "keys": ["ctrl+q", "ctrl+a"], "command": "show_panel", "args": {"panel": "replace"} }, { "keys": ["ctrl+q", "ctrl+y"], "command": "run_macro_file", "args": {"file": "Packages/Default/Delete to Hard EOL.sublime-macro"} }, { "keys": ["super+ctrl+alt+left"], "command": "navigation_history_back"}, { "keys": ["super+ctrl+alt+right"], "command": "navigation_history_forward"} ]
追記
印刷できない原因だが、どうやら Syntax として PHP を選択した時に起きるようだ。編集中の PHP ファイルの Syntax を他のものにすると、ふつ〜にブラウザで開くことができる。
調べてみると Print to HTML というプラグインが PHP に対応していない という恐ろしい事実が発覚した。警告メッセージくらい出してほしいものだ。
とりあえずは、PHP を印刷するときは一時的に別の Syntax に切り替えるという技を使うことにした。Sublime Text 3 は大丈夫なのかな?