What is `/usr/bin/vi`?

when i execute /usr/bin/vi it opens neovim.
my $EDITOR is /usr/bin/vi
my /usr/bin/vi is not a link, and only 1 hard link to it exists
the bundle “vim-minimal” is not installled
i have both vim and neovim installed
/usr/bin/vi is 14Ki while /usr/bin/nvim is 3.8Mi
what is /usr/bin/vi?

running /usr/bin/vi on my system without vim-minimal installed opens VIM - Vi IMproved version 8.2.4611

The same happens after installing vim-minimal

Running $EDITOR opens the same program.

Neovim is not installed.

The /usr/bin/vi binary is a special wrapper program written in C that follows this logic:

  1. If /usr/bin/nvim exists, run /usr/bin/nvim.
  2. Otherwise, if /usr/bin/vim exists, run /usr/bin/vim.
  3. Otherwise, if /usr/bin/vim-minimal exists, run /usr/bin/vim-minimal.
  4. Otherwise, run /usr/bin/false, effectively returning an error code immediately.

More background about “why it exists”:

In October 2017, we created a project named usrbinpython that installed a binary named /usr/bin/python that executed python2 if it was installed, and would otherwise execute python3. We flipped the logic in February 2018: that is, /usr/bin/python would prefer to run python3 if possible.

Later, we created two other projects, usrbinjava (repo link) and usrbinvi, that serve a similar purpose: to make a (fixed) decision about which versions (or variants) of a program to run if a generic program name is executed.

To be fair, one can argue that if /usr/bin/vi exists, it should run the traditional VI editor when called. I think there’s a better argument for /usr/bin/vi to not be a wrapper program compared to /usr/bin/java or /usr/bin/python. The latter two programs are selecting a preferred version of Java or Python to run, and the preference is defined by the OS contributors. For /usr/bin/vi, it’s a variant preference, and there are fewer reasons from an “OS operations” perspective to inform what that preference should be…

I hope this clarifies the situation :slight_smile: The outcome of running /usr/bin/vi (on Clear Linux OS) will vary depending on what bundles you have installed, and this behavior is by design.