Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to set editor used by sudoedit

📅 2015-Jan-23 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ editor, update-alternatives ⬩ 📚 Archive

sudoedit is the recommended command to use to edit files owned by the superuser. On many systems, it uses the nano editor to open these files. You might prefer to use a different editor like Vim to edit these files.

The man page for sudoedit says that the editor used is decided based on the environment variables EDITOR, SUDO_EDITOR or VISUAL. Setting these variables proved to be useless, since it did not affect the editor used by sudoedit.

The method that works is to run sudo update-alternatives --config editor and choose your preferred editor from the list that is displayed. It works and sudoedit starts using the editor you picked.

Tried with: Raspbian 7

© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘📧