Laptop Hand

Vi Help

New to Vi?

Find out what Vi does, what Vi does not do, where Vi comes from and when to run Vi.

What does it do?

Vi (pronounced vee-eye) is a text editor. It allows you to edit files interactively and visually see the changes at the same time.

The original Vi is a modal editor consisting of two modes: normal mode and insert mode. In normal mode, keystrokes are interpreted as commands (i.e. – “j” moves down one line and “k” moves up one line). In insert mode, keystrokes are typed directly into the file being edited. Many of the text editor applications we are familiar with consist of only a single insert mode: Microsoft Word, Notepad, Wordpad, and even the email editor web applications (i.e. – Gmail).

What does it not do?

The original Vi text editor does not format the text in your files. Bold, italics, underlining, font size, font color (the list goes on) are not features of Vi. Vi does not do spell-checking. Vi does not do any syntax highlighting for programming languages like Perl, Python, etc.

As over 30 years have gone by since vi was created, many clones have been created: Stevie, Elvis, nvi and Vim, just to name a few. Many of these clones have plug-ins that support spell-check, syntax highlighting, and much more.

Where does it come from?

Vi is the visual mode of  a line editor called ex.

However, it all started with ed which is a UNIX command line editor for teletypes. ed was written by Ken Thompson in 1971. In February 1976, George Coulouris modified Thompson’s code and created em editor which is designed for display terminals. Bill Joy and Chuck Haley then took em, modified it to create en, and then modified that to create ex.

In October 1977, vi was born from the mind of Bill Joy. It was officially released as the visual mode of ex 1.1 in the first BSD Unix release in March 1978. Seeing the popularity of the visual mode, ex 2.0  included a short-cut to go directly to the visual mode by using the command vi.

When should you run it?

Anytime you need to edit a text file, vi can be run. For example, to edit help.txt, type: vi help.txt. Vi will launch and display the contents of help.txt.It is important to avoid the use of vi in the presence of an adamant EMACS user (especially Church of EMACS members). The possibility of being insulted, attacked or even becoming the target of an evangelistic conversion process are all within the realm of reality. In all seriousness, the vi vs. EMACS debate is an on-going rivalry that will likely have no end. Caveat emptor… 🙂

Next Steps

Check out some of the references below for more information about vi and its family of clones. If Vi gives you a warm fuzzy feeling, make sure to check out Vim … the de facto Vi clone these days. It even has a great support for Windows!

References

Wikipedia – Vi
http://en.wikipedia.org/wiki/Vi

The Vi Lovers Home Page
http://thomer.com/vi/vi.html

Wikipedia – Ed (text editor)
http://en.wikipedia.org/wiki/Ed_(text_editor)

Vim, The Editor
http://vim.sourceforge.net/

An Introduction to Display Editing with Vi
http://docs.freebsd.org/44doc/usd/12.vi/paper.html

Wikipedia – Editor War
http://en.wikipedia.org/wiki/Editor_war

Emacs – The Sacred Editor

About the Author

Ray Li

Ray is a software engineer and data enthusiast who has been blogging for over a decade. He loves to learn, teach and grow. You’ll usually find him wrangling data, programming and lifehacking.

Comments 4

  1. I’m a long-term vim user, and recently found these two aids which have helped me to deepen my usage of it:
    * http://naleid.com/blog/2010/10/04/vim-movement-shortcuts-wallpaper/
    * http://michael.peopleofhonoronly.com/vim/

    Also there was this great story that hit Hacker News today about how someone used vim (plus gnu screen) as a crucial aid in switching to using an ipad as their main development platform: http://yieldthought.com/post/12239282034/swapped-my-macbook-for-an-ipad .

  2. Oh and in that arstechnica article, I found this comment incredibly ironic:
    > It also has a built-in version of the grep command

    That’s really a bit of a ret-con since the grep command was named after the vi colon command “g/…/p”. This uses the global command “g” print (action “p”) lines matching the … regex. So “grep” basically means global-regex-print, which is a vi command structure.

    1. @Josh: Great to hear from you! Thanks for posting the links and the interesting note about grep. Happy birthday, Vim! 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

16 + 5 =

This site uses Akismet to reduce spam. Learn how your comment data is processed.