t8m8-mem8

競プロとか、学んだことを書いていきます。

El Capitan に Sublime Text 3 を入れ直したからまとめた

El CapitanをクリーンインストールしたのでSublime Textを今まで使ってた状態に戻す。
せっかくなのでやったことをまとめる。
VSCode? Atom? 聞こえない聞こえない。

Sublime Text 3をインストール

今まではhomebrew-caskでいれていたけれど、homebrew-caskは今後使うのを止めることにしたので

Sublime Text - Download

から普通に落としてきた。

Package Controlをいれる

Installation - Package Control

ここに書いてある通りにいれる。

プラグインを追加

とりあえず以下のものを入れた。
下の3つはあんまり使ってないかも。

Vimライクにする

以下のプラグインを入れる。

Preferences.sublime-settingsに以下を追加

{
    // vim mode
    "vintage_ctrl_keys": true,
    "vintage_use_clipboard": true,
}

【Sublime Text】愛好家必読!Vim化しよう - 悲しいけど、オレ素人プログラマなのよね

この記事とかを参考にキーバインドを設定する。
ただし、jを2回押しでinsertを抜ける設定は上の記事通りに記述すると、抜けた直後の入力が1回キャンセルされてしまう。
以下のように書くといい感じに動く。

{
    "keys": ["j", "j"],
    "command": "_enter_normal_mode",
    "args": {"mode": "mode_insert"},
    "context": [
        {"key": "vi_insert_mode_aware"}
    ]
},

かっこよくする

結局エディタなんて見た目が一番大事なんだよ!!!
ということで、僕のお気に入りを紹介する。
最終的にはこんな感じになる。

f:id:t8m8:20151122021032p:plain

テーマを変更する

Preferences.sublime-settingsに以下を追加。

{
    // Seti_UI
    "theme": "Seti_orig.sublime-theme",
    "Seti_ClosedFolder_same": true,
    "Seti_SB_bright": true,
    "Seti_blue_tab_label": true,
    "Seti_no_bar_undertabs": true,
    "Seti_rainbow": true,
    "Seti_sb_small_padding": true,
    "Seti_sb_tree_small": true,
    "Seti_tabs_med": true,
}

カラースキームを変更する

Preferences.sublime-settingsに以下を追加。

{
    // Mirodark
    "color_scheme": "Packages/Mirodark Color Scheme/MirodarkHighContrast.tmTheme",
}

フォントを変更する

Preferences.sublime-settingsに以下を追加。

{
    // Migu 1M
    "font_face": "Migu 1M",
}

アイコンを変更する

好きなアイコンを探してくる。

Dribbble - Sublime Text icon replacement for Flatland Theme by Ernest Ojeh

僕は毎回このアイコンを落としてくる。
アプリケーションフォルダのSublime Text 3を右クリック→「情報を見る」をクリック
落としてきたicnsファイルを今のアイコンの上にドラッグして起動しなおすと変更できる。

f:id:t8m8:20151122015547p:plain

できた。

ターミナルから起動できるようにする

El Capitanからは

$ sudo ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl

を叩くと

$ subl {filename}

でファイルをsublimeで開くことができるようになる。
リンクを貼る先が変わったのはRootlessの影響なんだろうか。


最終的な設定ファイル

Preferences.sublime-settingsはこれまでの内容に基本設定をいくつか追加してこんな感じになった。

{
    // vim mode
    "vintage_ctrl_keys": true,
    "vintage_use_clipboard": true,

    // Seti_UI
    "theme": "Seti_orig.sublime-theme",
    "Seti_ClosedFolder_same": true,
    "Seti_SB_bright": true,
    "Seti_blue_tab_label": true,
    "Seti_no_bar_undertabs": true,
    "Seti_rainbow": true,
    "Seti_sb_small_padding": true,
    "Seti_sb_tree_small": true,
    "Seti_tabs_med": true,

    // Mirodark
    "color_scheme": "Packages/Mirodark Color Scheme/MirodarkHighContrast.tmTheme",

    // Migu 1M
    "font_face": "Migu 1M",

    "font_size": 11,
    "highlight_line": true,
    "scroll_past_end": true,
    "overlay_scroll_bars": "enabled",
    "trim_trailing_white_space_on_save": true,
    "caret_style": "phase",
    "default_encoding": "UTF-8",
    "trim_automatic_white_space": false,
    "file_exclude_patterns":
    [
        "*.pyc",
        "*.pyo",
        "*.exe",
        "*.dll",
        "*.obj",
        "*.o",
        "*.a",
        "*.lib",
        "*.so",
        "*.dylib",
        "*.ncb",
        "*.sdf",
        "*.suo",
        "*.pdb",
        "*.idb",
        ".DS_Store",
        "*.class",
        "*.psd",
        "*.db"
    ]
}

Default (OSX).sublime-keymapはこんな感じ。

[
{
    "keys": ["g", "t"],
    "command": "next_view",
    "context": [
        { "key": "setting.is_widget", "operand": false },
        { "key": "setting.command_mode" }
    ]
},
{
    "keys": ["g", "T"],
    "command": "prev_view",
    "context": [
        { "key": "setting.is_widget", "operand": false },
        { "key": "setting.command_mode" }
    ]
},
{
    "keys": ["j", "j"],
    "command": "_enter_normal_mode",
    "args": {"mode": "mode_insert"},
    "context": [
        {"key": "vi_insert_mode_aware"}
    ]
},
{
    "keys": ["ctrl+j"],
    "command": "exit_visual_mode",
    "context": [
        { "key": "setting.command_mode"},
        { "key": "num_selections", "operand": 1},
        { "key": "selection_empty", "operator": "equal", "operand": false, "match_all": false }
    ]
},
{
    "keys": ["tab"],
    "command": "move",
    "args": {"by": "characters", "forward": true },
    "context": [
        { "key": "following_text", "operator": "regex_contains", "operand": "^[)}'\"\\]]", "match_all": true },
        { "key": "auto_complete_visible", "operator": "equal", "operand": false }
    ]
},
{
    "keys": ["tab"],
    "command": "auto_complete",
    "context": [
        { "key": "auto_complete_visible", "operator": "equal", "operand": true }
    ]
},
{
    "keys" : ["shift+tab"],
    "command" : "hide_auto_complete",
    "context" : [
        { "key" : "auto_complete_visible", "operator": "equal", "operand": true }
    ]
}
]

他にも競プロ用のスニペットを登録したりとかしてる。

イカしてるプラグインとかあったら教えてください。
おわりー。