13

How do I install the vi editor in Ubuntu 18.04? I want to try vi, not vim. I am just curious to see how it works. Thanks!

Pablo Bianchi
  • 17,371
eeze
  • 223
  • 1
  • 3
  • 11

3 Answers3

12

There's no such thing as "original" vi on Linux.

If one wants to try the original flavor of vi, there are a few options:

  1. vim.tiny as the other answer suggested.

  2. run busybox vi, busybox-static is default installed on 18.04/18.10. This version is a very small clone of vi.

  3. The traditional vi project, run by Gunnar Ritter, the first one who ported vi to Linux. You need to compile from source for this one.

pirt
  • 103
Alvin Liang
  • 1,753
11

To install vi in all currently supported versions of Ubuntu open the terminal and type:

sudo apt install vim-tiny

This package contains a minimal version of Vim compiled with no GUI and a small subset of features which runs with 'compatible' set, no language bindings, no X/GUI support. This package's sole purpose is to provide the vi binary for base installations.

If a vim binary is wanted, try one of the following more full-featured packages: vim, vim-nox, vim-athena, vim-gtk, or vim-gtk3.

To edit a file named FILE in vi type:

vi /path/to/FILE  

Results of which vi :

/usr/bin/vi

Results of update-alternatives :

$ update-alternatives --list vim
/usr/bin/vim.gtk3
$ update-alternatives --list vi
/usr/bin/vim.gtk3
/usr/bin/vim.tiny
$ update-alternatives --config vi
There are 2 choices for the alternative vi (providing /usr/bin/vi).

Selection Path Priority Status

  • 0 /usr/bin/vim.gtk3 50 auto mode 1 /usr/bin/vim.gtk3 50 manual mode 2 /usr/bin/vim.tiny 15 manual mode

Press <enter> to keep the current choice[*], or type selection number:

karel
  • 122,292
  • 133
  • 301
  • 332
3

This is really late, but the closest you will get to a vi "package" install in Ubuntu is "nvi" -- "new vi." This is the version that was written for BSD before the original source code was opened. It is still used in the BSDs to this day. There are still a few "add-ons" compared to "true vi", but it is vastly closer to vi than "vim-tiny". The add-ons are true enhancements, not outright changes AFAIK, except where Keith was dealing with differences / updates between the POSIX & vi specs. This can be contrasted with many of vim's IMprovements.
Anyone who implies vim-tiny or vim-minimal is somehow the "same" as vi is misguided at best. The differences in "undo" (especially ^R) are enough to break the workflow of many people who use "real vi."

Pointing vim, vim-tiny, or elvis to "vi" does not make it vi. That is like claiming symlinking bash to /bin/sh forces people to write POSIX-compliant shell scripts.

nvi comes from the "elvis" lineage as did vim, but nvi is intended to be "bug-for-bug compatible" with real vi. Upside is that it also comes with "nvi-doc" which is some of the best vi tutorials around, IMO.

First thing I do on a Devuan box is "apt install nvi ; apt remove nano vim*"

nvi-doc also does not require a 33 Mb "vim" install, like "vimtutor" seems to. The fact that the 33Mb "vimtutor" is based on an old, freely available, 30Kb Unix vi tutor is another story: http://pages.cs.wisc.edu/~amos/vi/vi.tut

Some Debian-based repos also have "elvis-tiny" hidden in there, but you are much better off compiling https://github.com/n-t-roff/heirloom-ex-vi vs using vim|elvis-tiny as others have said. Even the description for elvis-tiny suggests you use something else... Slackware's default "vi" is a "full build" of elvis, which is much more usable but it has too many non-standard configuration settings for my taste.

Just make sure to have gcc, make, and libtinfo-dev if you go to compile ex-vi.

When in doubt, just type :version in command mode and you will see what your "vi" really is.

Kajukenbo
  • 131