Vi Introduction and Resources

Vi is a text editor originally created for the Unix operating system. Instead of menus, vi uses combinations of keystrokes in order to accomplish commands. As such, there is no need for the use of a mouse or a touchpad — everything is done exclusively with the keyboard.

Brief History

Vi traces its origins back to the earliest command line editor used in Unix systems called ed. Ed worked extremely well with teletypes but wasn't suited for display terminals. Quite a few people considered ed unfriendly and took it upon themselves to create a better version. Among them is George Coulouris, at the time a lecturer at Queen Mary College, who created em, the editor designed for display terminals.

In 1976, he visited UC Berkeley and showed em to various people. The reactions were mixed but a couple of students, Bill Joy and Chuck Haley, were impressed with em and used it as the base for their own editor called en which was then extended to create ex version 0.1. After Haley left Berkeley, Joy redesigned the editor in 1977, when he added a full-screen visual mode to ex, allowing text to be viewed on a full screen rather than only one line at a time.

Ex 1.1 was officially included in the first BSD Unix release in 1978 and it became known as vi after the release of ex 2.0 as part of the second Berkeley Software Distribution in 1979 when the editor was installed under the name "vi" because it automatically took users straight into ex's visual mode.

vi Clones

Considering the fact that the source code for the original vi wasn't freely available until 2002, many clones of the vi editor were created. They had similar appearance and functionality, but were written entirely from scratch. This made it possible to add more features and port the editor to other operating systems.

The list of vi clones includes calvin, elvis, elwin, lemmy, nvi, stevie, vile, viper, BusyBox, and xvi. The most popular clone, though, is Vim, which is an improved version of the vi editor distributed with most UNIX systems.

Vim

Vim stands for Vi IMproved and it includes even more features than vi, making it a favorite among many programmers. The features include (scriptable) syntax highlighting, mouse support, graphical versions, visual mode, new editing commands, and extensions for ex commands. It's included with almost every Linux distribution and ships with every copy of Apple MacOS.

Because of the fact that some vi features are missing from Vim, it has a vi compatibility mode, which makes it conform more strictly with vi. This feature can be controlled by the :set compatible option.

Vim can be customized in many ways — including its user interface and basic functionality. You can define personalized macros to automate sequences of keystrokes, set internal user functions, and take advantage of numerous plugins which add new functionality to Vim. The plugins are written in Vim's internal scripting language called vimscript. It also supports scripting using Lua, Perl, Python, Ruby, Tcl, and Racket.

Resources

Quite a few resources are available for vi as well as for Vim, which is more predominant nowadays.

Online Resources

The following resources consist of various articles, tutorials, and even cheat sheets.

  • The Traditional Vi: the official homepage for the vi editor with download links.
  • Vi FAQ: a great place to start as it answers some of the most commonly asked questions about vi and why it's worth learning it.
  • An Introduction to Display Editing with Vi: a tutorial on vi geared for more advanced users, covering its features and how to use it.
  • Vi Manual Page: provides a description of the available commands.
  • Unix — The Vi Editor Tutorial: a very short and to the point tutorial for vi, aimed at complete beginners.
  • How to Use Vi: another tutorial aimed at complete beginners to serve as a "gentle introduction" to the editor, but it can also be used as a reference material for intermediate users.
  • Vi Cheat Sheet: a handy cheat sheet of the core vi commands.
  • Vim: the official homepage for Vim.
  • Interactive Vim Tutorial: like the name suggests, this tutorial is interactive — emulating the command line and the keyboard right in your browser so you can test it out and learn Vim without the fear of breaking your computer.
  • Graphical Vi-Vim Cheat Sheet and Tutorial: a graphical cheat sheet showing the core commands on a keyboard GIF with an accompanying tutorial.
  • Vim Awesome: a fairly large collection of plugins for Vim.

Video Tutorials

Several video tutorials are available, if you prefer to learn as you go along.

  • The Vi/Vim Editor: an introductory tutorial on how to use the vi/vim editor, including how to open a file, insert text, write the text to a file, and quit vi.
  • Learn to Love Vim: not a tutorial per se, but it highlights why you should use Vim.
  • Learning Vim in a Week: a talk presented by Mike Coutermash, based on his blog post Learning Vim in a Week. Aimed at beginners, it covers getting up and running with Vim.

Books

Given the popularity of both vi and Vim, the following books cover the editors in great depth.

  • Learning the Vi and Vim Editors (2008) by Robbins, Hannah, and Lamb: covers editing basics and advanced tools for both editors and programmers, such as multi-window editing, how to write both interactive macros and scripts to extend the editor, and more.
  • Vi and Vim Editors Pocket Reference (2011) by Arnold Robbins: covers the most valuable commands for vi, Vim, and vi's main clones.
  • Mastering Vim (2014) by Damien Conway: best suited for intermediate users, covers Vim's more advanced features, configuration options, and several plugins that make the editing experience better.

Learn Vi Starting Now

Despite numerous clones and features added to them, learning vi allows you to use its clones more productively and helps in situations where vi is the only editor available. The above resources will help you become a vi master in no time.


Further Reading and Resources

We have more guides, tutorials, and infographics related to coding and development:

  • Mantis Hosting: find out what web hosting companies offer good deals that include this popular bug tracking program.
  • Ubuntu Primer: learn all about one of the most popular Linux distributions.
  • Object-Oriented Programming: learn about the wide range of object-oriented programming languages — some may surprise you.

Would the Internet Survive the End of the World?

Have you ever wondered what a major catastrophe would do to the internet? Check out our infographic, Would the Internet Survive the End of the World? It's possible we could all be destroyed but the internet would live on.