Skip to content

Instantly share code, notes, and snippets.

@hiphamster
Last active June 19, 2019 20:42
Show Gist options
  • Save hiphamster/8df7e41a8fd0c8871dcafdc54bfe0258 to your computer and use it in GitHub Desktop.
Save hiphamster/8df7e41a8fd0c8871dcafdc54bfe0258 to your computer and use it in GitHub Desktop.
Setup vi / vim alternatives on mac and linux

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment