Chapter 17. vi Tips and Tricks

The vi Editor: Why So Much Material?

We’re giving a lot of pages to the vi editor. People who use another editor, like Emacs, might wonder why. Here’s why.

I’ve watched people (including myself) learn and use vi for 20 years. It’s the standard editor that comes with almost every Unix system these days, but most people have no idea that vi can do so much. People are surprised, over and over, when I show them features that their editor has. Even with its imperfections, vi is a power tool. If you work with files, you probably use it constantly. Knowing how to use it well will save you lots of time and work.

But why not give the same coverage to another editor that lots of people use: GNU Emacs ( Section 19.1)? That’s because GNU Emacs comes with source code and can be extended by writing LISP code. Its commands have descriptive names that you can understand by reading through a list. vi’s commands are usually no more than a few characters long; many of the option names are short and not too descriptive either. Lots of Unix systems don’t even have vi source code these days.

I hope that you vi users will learn a lot in this section and that people who don’t use vi will at least browse through to see some of vi’s less obvious features.

If you’re looking for additional text-editing power, you can use vim instead of the plain vanilla vi installed on most systems. All vi commands work with vim, but with added functionality, power, and more standardized behavior ...

Get Unix Power Tools, 3rd Edition 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.