10

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!

5
  • vi is generally installed by default. vi didn't use arrow keys as few terminals had arrow keys in the 70s, where I think vim-tiny has the arrow keys enabled, , but if you want the full vi experience - just don't use your arrow keys.
    – guiverc
    Dec 9, 2018 at 5:42
  • 1
    What exactly do you mean by vi here?
    – muru
    Dec 9, 2018 at 5:52
  • Possible duplicate of How do I install applications in Ubuntu?
    – N0rbert
    Dec 9, 2018 at 8:02
  • 2
    @N0rbert "How do I install applications in Ubuntu?" is a duplicate of many software installation questions, but it's not a duplicate of this question because there are multiple vim packages in the default Ubuntu repositories and the linked question does not answer how to select a package for installation when there are multiple alternative packages available in the default Ubuntu repositories.
    – karel
    Dec 9, 2018 at 9:10
  • 3
    @Norbert the original vi is not in the Ubuntu repositories any more. Dec 13, 2018 at 10:23

3 Answers 3

10

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:
3
  • 1
    is vim-tiny 100% vi compatible, with no additions? I am really wanting to try out plain vi to see what it is like.
    – eeze
    Dec 9, 2018 at 4:58
  • 2
    @Cee VIM stands for Vi IMproved (as per VIM official documentation). So, vim-minimal (No GUI) and vi must be somewhat same. You might like to read Biggest differences between Vim and VI - Vi and Vim Stack Exchange
    – Kulfy
    Dec 9, 2018 at 9:40
  • @eeze No, vim-tiny is nowhere close to traditional vi. In fact, vim-tiny is the default vim that comes with Ubuntu. Even a minimal vim will have tons more features than vi. For example, vim-tiny supports arrows in Insert Mode, split windows (:sp), tabs (:tabnew myfile), etc. See vim faq 1.4 or :help vi_diff for the full list. To try real vi, try the other options in Alvin's answer.
    – wisbucky
    Jul 17, 2019 at 0:31
9

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.

2
2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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