saitti/docs/programming/custom-default-editor.md
2025-01-24 05:27:39 +02:00

608 B

Custom default editor

If you'd like to for example open #emacs with -nw you need to do some trickery.

Create a script to open the editor and set it executable

#!/bin/sh
emacs -nw "$@"

Add the script to list of known editors (if using update-alternatives system) and set it default:

$ sudo update-alternatives --install /usr/bin/editor editor /usr/local/bin/emacs-nw 2;
$ sudo update-alternatives --config editor;

You may also set variables in ~/.bashrc like so:

export VISUAL="emacs"
export EDITOR="emacs -nw"