How to install vi (not vim)?

17,770

Solution 1

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

If one wants to try the original flavor of vi, there's several versions he can try.

  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.

Solution 2

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:

Solution 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.

Share:
17,770

Related videos on Youtube

eeze
Author by

eeze

Updated on September 18, 2022

Comments

  • eeze
    eeze over 1 year

    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!

    • guiverc
      guiverc over 5 years
      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.
    • muru
      muru over 5 years
      What exactly do you mean by vi here?
    • N0rbert
      N0rbert over 5 years
    • karel
      karel over 5 years
      @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.
    • Warren Hill
      Warren Hill over 5 years
      @Norbert the original vi is not in the Ubuntu repositories any more.
  • eeze
    eeze over 5 years
    is vim-tiny 100% vi compatible, with no additions? I am really wanting to try out plain vi to see what it is like.
  • Kulfy
    Kulfy over 5 years
    @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
  • wisbucky
    wisbucky almost 5 years
    @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
    wisbucky almost 5 years
    Confirmed that github.com/n-t-roff/heirloom-ex-vi compiles and runs great (tested on Ubuntu 18.04). You can verify it is traditional vi by trying to use the arrow keys in Insert Mode (it will type "A, B, C, D" instead of moving the cursor).
  • wisbucky
    wisbucky almost 5 years
    vim.tiny is nowhere close to traditional vi. See my comment for askubuntu.com/questions/1099484/how-to-install-vi/…