2

I constantly see tutorials, YouTube videos, colleagues at work, and even books stating that you can edit files using the "vi" editor.

My main concern here is that vi, as in the original application from the mid 70s, is not even being packaged with Linux distros anymore, and this has been the case for a number of years.

Why does the vi command exist in Ubuntu and what would be the advantage of running it compared to vim?

This all came to my mind now as I am reading an Ansible tutorial and one of the "tips" is:

You can type vi at the terminal to open the Vi editor

This tutorial is from 2018.

I know that when you type vi, it actually runs vim.tiny in many distros.

  • 1
    We don't know why these people type vi; you need to ask them, not us. – fkraiem Aug 26 '19 at 4:59
  • 2
    I think the core of this question as I understand it--why it is useful to run and suggest vi, and what advantage it may have over recommending vim--is good. But I very much agree with fkraiem that the minds of your colleagues and of people who make tutorials, videos, and books, is not something that can be answered here, nor is it something that would likely be on-topic (see the help center) even if it were answerable. For my answer, I've interpreted this as asking why the vi command exists in Ubuntu and what the considerations are in recommending or running it compared to vim. – Eliah Kagan Aug 26 '19 at 5:15
  • I am one of these people, I have been using vim on Linux since 2001. If I type vi I start vim. Typing vi is shorter than typing vim, it does what I want and is what my fingers remember. Why would I do anything else? That said when writing a tutorial I might type vim to avoid confusion but I might forget to do this, which is probably what is happening in most of these cases. – htaccess Aug 26 '19 at 9:31
10

A freshly installed Ubuntu system has a vi command and does not have a vim command. In this configuration, vi is a symlink that ultimately resolves to vim.tiny, as you mentioned. However, if one of the other packages that provides a Vim binary such as vim.nox or vim.gtk3 (provided by the vim-nox and vim-gtk3 packages) is installed, then vi, as well as vim, will be symlinks that ultimately resolve to that more fully featured binary. You can reconfigure that but people rarely do. Running vi is thus a fairly reliable way to open a vi-like editor.

As for why people sometimes call it vi, you're right that this is somewhat imprecise. Part of this is typographical. It's a vi command, after all. Part of it is that there is not necessarily a better name. The vi-like editor that provides the vi command need not be Vim; there are various other vi-style editors that one might configure for that even in Ubuntu, not to even get started on other systems. (You asked this question on Ask Ubuntu, so I presume you're interested in this mainly in the scope of Ubuntu.)

But part of it is that the vi command in Ubuntu is one of numerous commands that have a traditional name but are really a different program more properly known by some different name. For example, people sometimes call /bin/sh the "Bourne shell." That isn't correct on most Unix-like systems these days, nor is it ever correct on Ubuntu or other GNU/Linux systems. When speaking generally--and accounting for how it's provided by different shells in different OSes and that an administrator can change what shell provides it--it would be better to say the "POSIX-compatible shell," or, perhaps even better, "shell that mostly tries to comply with POSIX requirements for sh, at least when it sees that it is named sh."

Just as the Bourne shell was not compatible with the older Thompson shell and yet was called sh, and just as POSIX shell implementations aren't compatible with the Bourne shell yet are called sh (or are, in any case, often run through a symlink called sh), many systems including Ubuntu ship a command that isn't the original vi editor yet is called vi. You're right that this is not really vi--unless what one means by that is whatever editor may be run by entering the vi command, which is what people often mean.

Incidentally, as you're likely aware, vim.tiny does behave in a more traditional manner--and it has a more traditionally constrained feature set--than commands like vim.nox. So that is another way in which the vi command in an Ubuntu system that hasn't had additional Vim-related packages installed is like vi.

  • 1
    I think this answer gets at the core of what is being asked here, especially in light of the OP's chosen title. I've not tried to answer parts of the question that seem to me to call for unbounded speculation or that I strongly suspect would be considered off-topic. I've made this answer community wiki so it is easier for others to edit, since I suspect (and also hope) that the question will change form somewhat to become a better fit for the site, and when that happens this answer may need to be adjusted. People should still of course be willing to post their own answers. – Eliah Kagan Aug 26 '19 at 5:08
3

Two reasons

  1. Because vi is specified by POSIX standard and will be available on all POSIX compliant systems including Ubuntu, whereas vim is GNU version. You should not focus on vi vs vim, focus on consistent behavior and functionality. See https://pubs.opengroup.org/onlinepubs/009695399/utilities/vi.html.

  2. There exists more than one clone of vi.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.