Полезная информация

UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: V. Text Editing Chapter 30Next: 30.2 What We Cover
 

30. vi Tips and Tricks

Contents:
The vi and ex Editors: Why So Much Material?
What We Cover
Mice vs. vi
Editing Multiple Files with vi
Edits Between Files
Local Settings for vi and ex
Using Buffers to Move or Copy Text
Get Back What You Deleted with Numbered Buffers
Using Search Patterns and Global Commands
Confirming Substitutions in ex and vi
Keep Your Original File, Write to a New File
Saving Part of a File
Appending to an Existing File
Moving Blocks of Text by Patterns
Useful Global Commands (with Pattern Matches)
Counting Occurrences; Stopping Search Wraps
Capitalizing Every Word on a Line
Setting vi Options Automatically for Individual Files
Modelines: Bug or Feature?
Multiple Editor Setup Files; Starting with a Search
Per File Setups in Separate Files
Filtering Text Through a UNIX Command
Safer vi Filter-Throughs
vi/ex File Recovery vs. Networked Filesystems
vi -r May not Write Recovered Buffer When You Exit
Shell Escapes: Running One UNIX Command While Using Another
vi Compound Searches
Keep Track of Functions and Included Files with ctags and tags
Setting Multiple tags Files
vi Outsmarts Dual-Function Function Keys
vi Word Abbreviation
Using vi Abbreviations as Commands (Cut and Paste Between vi's)
Fixing Typos with vi Abbreviations
vi Line Commands vs. Character Commands
Out of Temporary Space? Use Another Directory
The ex Open Mode Can Be Handy
Neatening Lines
Finding Your Place with Undo

30.1 The vi and ex Editors: 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 15 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 warts, 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 (32.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.

- JP


Previous: V. Text Editing UNIX Power ToolsNext: 30.2 What We Cover
V. Text Editing Book Index30.2 What We Cover

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System