7

Editing Files with Vi

There are many ways to edit files in Unix, including the use of early line-based text editors such as ed (EDitor) and ex (EXtended) and the use of screen-oriented text editors such as Emacs (Editor MACroS) and vi (VIsual editor). Line editors allow you to edit a file only line by line; screen editors enable you to edit lines in context with other lines in the file. Vi is generally considered the de facto standard in Unix editors because:

  • It's usually available on any Unix system. Once you have learned how to use it, there is no learning curve when you're working on another Unix system, which allows for faster recovery or adjustments of files.
  • Vi implementations are very similar across the board (from Linux, to Mac OS X, to Sun Solaris, and so on).
  • It requires very few resources.
  • It is more user friendly than ed or ex.

Vi is pronounced “vee eye.” There is a popular joke about a newbie (someone new to Unix or to computers in general) asking a more seasoned Unix veteran when the Seven (VII) editor would be coming out because Six (VI) seemed outdated.

Nearly everyone who uses Unix will need to know how to use vi at one time or another, especially in situations with limited resources (where no graphical user interface [GUI] is present or where minimal resources are available). Vi can be intimidating to new users, especially those who are used to graphically oriented word processors. Vi is purely a functional text editor, and no fancy formatting can be accomplished ...

Get Beginning Unix now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.