Linux
Debian-based systems i.e. Ubuntu have update-alternatives
, a system that maintains symbolic links to default commands
From the man
page:
EXAMPLES
There are several packages which provide a text editor compatible with vi, for example nvi and vim.
Which one is used is controlled by the link group vi, which includes links for the program itself
and the associated manpage.
To display the available packages which provide vi and the current setting for it, use the --display action:
update-alternatives --display vi
To choose a particular vi implementation, use this command as root and then select a number from the list:
update-alternatives --config vi
To go back to having the vi implementation chosen automatically, do this as root:
update-alternatives --auto vi
Mac and macports
Macports has port select
, which is simmilar to update-alternatives. In order to configure vi
for example, copy an existing
select group from /opt/local/etc/select
to `/opt/local/etc/select/vi', and update symlink files:
/opt/local/etc/select/vi/base
- contains link to default (system) vi, sudo ln -s /usr/bin/vi /opt/local/bin/vi
/opt/local/etc/select/vi/nvim
- contains link to nvim binary
/opt/local/etc/select/vi/none
- empty
Then run sudo port select --set vi 1.0
, where vi
is the name of the group and 1.0 is the version
set nvim
as default, and you're done.