それマグで!

知識はカップより、マグでゆっくり頂きます。 takuya_1stのブログ

習慣に早くから配慮した者は、 おそらく人生の実りも大きい。

デフォルトで起動するエディタを変える

環境変数 EDITOR でも良いんですが。alternative システムを使うとeditor コマンドを自在に変えることが出来る。

alternatives システムは java や editor コマンドなど、複数の選択肢がある時に、どれを選択するかを事前に決めておく

editor コマンドを設定する

sudo update-alternatives --config editor

設定変更画面

takuya@host:~/test$ sudo update-alternatives --config editor

`editor' を提供する 5 個の alternatives があります。

  選択肢       alternative
-----------------------------------------------
          1    /usr/bin/vim.tiny
          2    /bin/ed
          3    /bin/nano
*         4    /usr/bin/vim.basic
 +        5    /usr/bin/vim.gnome

デフォルト[*] のままにするには Enter、さもなければ選択肢の番号のキーを押してください:

update-alternatives が何を変えたの?

変更前
takuya@host:~/test$ ls -alt  /etc/alternatives/editor
lrwxrwxrwx 1 root root 18 2010-10-21 18:43 /etc/alternatives/editor -> /usr/bin/vim.gnome
変更後
takuya@host:~/test$ ls -alt  /etc/alternatives/editor
lrwxrwxrwx 1 root root 18 2010-10-21 18:43 /etc/alternatives/editor -> /usr/bin/vim.basic # 指している位置が変わる


editor だと vim / ed と変えるんだけど、open-jdk と sun-jdk をどっちを使うとかにも使えます。redhat/centos でも使えます。