Appendix A. Using vi or Vim Editors

Although easy-to-use graphical text editors (such as TextEdit or BBEdit) are readily available on Mac OS X systems, most power users still use vi or Emacs to edit text files. Besides the fact that vi and Emacs will work from any shell (no GUI required), they offer other advantages, such as your hands never having to leave the keyboard and integration with useful utilities; and unlike GUI editors, text-based editors are usable over slow Internet connections such as dial-up or satellite.

This appendix focuses on features of the vi editor that not only help you with basic editing, but also help you do some advanced text manipulation. We chose to cover vi rather than Emacs because vi is more universal and leaner, and because vi keyboard shortcuts require only two arms. Because some UNIX-like systems use the Vim (Vi IMproved) editor instead of the older vi editor, the descriptions in this appendix are extended to cover Vim as well. Some features in Vim that are not in vi include multiple undo levels, syntax highlighting, and online help.


If you have never used vi or Vim before, try out the tutor that comes with the vim6 package. Run the vimtutor command and follow the instructions to step through many of the key features of vi and Vim. To see the differences between vi and Vim, type :help vi_diff.txt while ...

Get MAC OS® X UNIX® Toolbox: 1000+ Commands for the Mac OS® X now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.