Ksh /

Changing Default Editor

By default, many utilities such as vipw?, crontab?, and got will use the editor defined in the VISUAL or EDITOR environmental variables. If both are not defined, OpenBSD defaults to vi.

If you want to change the editor temporarily for your user, type:

$ export EDITOR=<program>
$ export VISUAL=<program>

Replace <program> with your actual editor.

To persist this change, add this to your ~/.profile:

$ echo "export EDITOR=<program>" >> ~/.profile
$ echo "export VISUAL=<program>" >> ~/.profile
$ . ~/.profile

The last line sources the file and sets the variables immediately.

To apply this change systemwide (including root user), add this to /etc/profile:

# echo "export EDITOR=<program>" >> /etc/profile
# echo "export VISUAL=<program>" >> /etc/profile
# . /etc/profile

For example, suppose we want to use an editor with emacs-like keybindings. To make mg? the default editor system-wide:

# echo "export EDITOR=mg" >> /etc/profile
# echo "export VISUAL=mg" >> /etc/profile
# . /etc/profile