LoginSignup
26
25

More than 5 years have passed since last update.

Sublime text2 のインストールと設定

Last updated at Posted at 2013-02-14

ダウンロード

Sublime Text: The text editor you’ll fall in love with

ダウンロードはここから。

他にも開発版のダウンロードもすることができる。
Dev Builds

Command Pallet を使う

TextMate と同様に Sublime Text2では Command + Shift + p で Command Pallet を開くことができる。
Command Pallet 上でコマンド名をタイプするとコマンドが絞り込まれていくので必要なコマンドを選択して実行することができる。

Package Control のインストール

Sublime Text2 をインストールしたら、まずはじめにやっておいた方がいいのが Sublime Package Control をインストール。
インストールするには control+`, またはメニューの View > Show Console でコンソールを立ち上げて下記のコマンドを実行する。

import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print('Please restart Sublime Text to finish installation')

実行後に再起動すると Package Control が使えるようになる。
Command Pallet を開き install で絞り込むと Package Controll: Install Package というコマンドがあるので Enter する。
実行するとクイックパネルに利用可能なパッケージが一覧表示されるので、インストールしたいパッケージの名前を入力する。
インストールのステータスはエディタ下部のステータスエリアで確認することができる。

Package Control で実行できるコマンドはこちらを参照。

各種設定

コマンドライン

まずはコマンドラインから Sublime Text2 を起動するために subl へのシンボリックリンクを作成する。

% ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl

OS X Commnad Line

ヘルプの参照

% subl --help

Sublime Text 2 Build 2217

Usage: subl [arguments] [files]         edit the given files
   or: subl [arguments] [directories]   open the given directories
   or: subl [arguments] -               edit stdin

Arguments:
  --project <project>: Load the given project
  --command <command>: Run the given command
  -n or --new-window:  Open a new window
  -a or --add:         Add folders to the current window
  -w or --wait:        Wait for the files to be closed before returning
  -b or --background:  Don't activate the application
  -s or --stay:        Keep the application activated after closing the file
  -h or --help:        Show help (this message) and exit
  -v or --version:     Show version and exit

--wait is implied if reading from stdin. Use --stay to not switch back
to the terminal when a file is closed (only relevant if waiting for a file).

Filenames may be given a :line or :line:column suffix to open at a specific
location.

テーマの適用

RailsCastsのテーマを適用する。
まず、以下のリンクからRailsCastsのテーマを取得する
Download RailsCasts Theme

設定方法

ダウンロードしたテーマファイルをSublime Text2のパッケージディレクトリへ配置する。

% cp ~/Downloads/Railscasts.tmTheme ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/

Sublime Text2を起動してメニューからSublime Text 2 > Preference > Color Scheme > Railscastsを選択する。

アイコンの変更

dmatarazzo / Sublime-Text-2-Icon から変更するアイコンを取得する。

以下のコマンドを実行することでアイコンが置き換わる。

% git clone git://github.com/dmatarazzo/Sublime-Text-2-Icon.git
% ./mac_replace_icons

手動でアイコンを置き換える場合は、ターミナルでopen /Applications/Sublime\ Text\ 2.app/Contents/Resources/を開いて icnsを上書きすればOK.

Dropbox で設定の共有

github を使って設定の共有をしたかったけど、方法がいまいち方法がわからなかったので Dropbox を使ってファイルの同期を設定した。

  1. Sublime Text 2 を終了させる。
  2. Dropbox に Sublime Text 2 ディレクトリを作成する。
  3. Sublime Text 2 の設定ファイルを Dropbox にコピーする。
  4. コピー元のファイルを削除する。
  5. シンボリックリンクを作成する。
% mkdir -p ~/Dropbox/Sublime\ Text\ 2/
% cd ~/Library/Application\ Support/Sublime\ Text\ 2/
% cp Installed Packages ~/Dropbox/Sublime\ Text\ 2/
% cp Pristine Packages ~/Dropbox/Sublime\ Text\ 2/
% cp Packages ~/Dropbox/Sublime\ Text\ 2/
% rm Installed Packages Pristine Packages Packages
% ln -s ~/Dropbox/Sublime\ Text\ 2/Installed\ Packages .
% ln -s ~/Dropbox/Sublime\ Text\ 2/Pristine Packages .
% ln -s  ~/Dropbox/Sublime\ Text\ 2/Packages .

参考:
Use Dropbox to store your Sublime Text 2 settings, themes and plugins

設定

Sublime Text2 > Preferences > Settings - Userから設定を編集できる。
Default の設定が評価されてから、Userの設定が評価されるので上書きしたい内容をUserの設定に記述する。

現在の設定 (2013-02-14)

{
    "auto_complete_commit_on_tab": true,
    "auto_complete_delay": 50,
    "bold_folder_labels": true,
    "caret_style": "phase",
    "color_scheme": "Packages/Railscasts.tmTheme",
    "default_encoding": "UTF-8",
    "draw_minimap_border": true,
    "draw_white_space": "all",
    "font_face": "Ricty Discord Regular",
    "font_size": 14,
    "highlight_line": true,
    "ignored_packages":
    [
        "Vintage"
    ],
    "indent_guide_options":
    [
        "draw_active",
        "draw_normal"
    ],
    "indent_to_bracket": true,
    "line_padding_bottom": 0,
    "line_padding_top": 0,
    "margin": 0,
    "match_brackets_angle": true,
    "overlay_scroll_bars": "enabled",
    "rulers":
    [
        80
    ],
    "scroll_speed": 1.0,
    "theme": "Phoenix Dark.sublime-theme",
    "translate_tabs_to_spaces": true,
    "trim_trailing_white_space_on_save": false,
    "word_wrap": false,
    "wrap_with": 80
}

キーマップ

[
    { "keys": ["super+alt+p"], "command": "show_overlay", "args": { "overlay": "command_palette", "text": "install"}},
    { "keys": ["alt+m"], "command": "markdown_preview", "args": { "target": "browser" } },

    // Ctrl + [でオートコンプリートのパネルを閉じる
    { "keys": ["ctrl+["], "command": "hide_auto_complete", "context":
        [
            { "key": "auto_complete_visible", "operator": "equal", "operand": true }
        ]
    }
]

インストールしたパッケージ (2013-02-14)

Packages/User/Package\ Control.sublime-settings

{
    "installed_packages":
    [
        "Abacus",
        "All Autocomplete",
        "Auto Encoding for Ruby",
        "BracketHighlighter",
        "Browser Refresh",
        "CTags",
        "Git",
        "GitGutter",
        "Gitignore",
        "Guard",
        "IndentGuides",
        "LiveReload",
        "Markdown Preview",
        "MarkdownEditing",
        "Package Control",
        "Ruby on Rails snippets",
        "RubyTest",
        "Search Stack Overflow",
        "Shell Turtlestein",
        "SideBarEnhancements",
        "SideBarGit",
        "SublimeLinter",
        "SublimePeek",
        "SublimeREPL",
        "SublimeServer",
        "Theme - Phoenix",
        "Theme - Soda",
        "TrailingSpaces"
    ]
}

さいごに

使い始めて2日目だけど、まだキーバインドが憶えられない。

26
25
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
26
25