Ubuntu 2204 修改預設 editor

Ubuntu環境下,如何更改預設的「editor」

操作說明
執行下面的指令,就可以設定改用其他慣用的文字編輯器了。

sudo update-alternatives --config editor

會出現一個類似如下的列表,選擇你預設要使用的文字編輯器就行了。

There are 4 choices for the alternative editor (providing /usr/bin/editor).

  Selection    Path                Priority   Status
------------------------------------------------------------
* 0            /bin/nano            40        auto mode
  1            /bin/ed             -100       manual mode
  2            /bin/nano            40        manual mode
  3            /usr/bin/vim.basic   30        manual mode
  4            /usr/bin/vim.tiny    15        manual mode

Press <enter> to keep the current choice[*], or type selection number:

我輸入「4」,按下「Enter」。

上面的操作完畢後驗證一下,看看是不是你想要預設使用的編輯器。

執行下面的指令

editor

或是執行下面的指令

sensible-editor

另外也可以直接執行下面的指令,更改成你慣用的文字編輯器

例如:

慣用 nano

sudo update-alternatives --set editor /bin/nan

慣用 vim.tiny

sudo update-alternatives --set editor /usr/bin/vim.tiny