Книга: Learning GNU Emacs, 3rd Edition
3.2.1 Simple Search and Replace Operations
3.2.1 Simple Search and Replace Operations
Assume you're in the situation we just described. You want to replace every occurrence of one string with another. You know that Whirligig is never correct, and there is absolutely no ambiguity about how you want to replace it. When you want to replace every instance of a given string, you can use a simple command that tells Emacs to do just that. Type M-x replace-string Enter, then type the search string and press Enter. Now type the replacement string and press Enter again. Emacs replaces all occurrences in the file from the cursor position onward. If you want to search and replace throughout the file, press M-< to go to the beginning of the file before typing this command. Here's a quick example of using replace-string.
Initial state:
Whirligig appears four times, but the cursor is positioned after the first instance.
Now we'll do the replacement.
Type: M-x replace-string Enter Whirligig Enter HealthBug Enter
Emacs replaces all instances from the cursor position onward.
The replacement occurs only from the cursor position onward; Whirligig in the first sentence is still incorrect. We'll work with this example again in a moment.
- Replace
- 3.2 Search and Replace
- Листинг 10.1. (simpleid.c) Отображение идентификаторов пользователя и группы
- 8.5.2 Typical Condition Variable Operations
- Разработка приложений баз данных InterBase на Borland Delphi
- Open Source Insight and Discussion
- Introduction to Microprocessors and Microcontrollers
- Chapter 6. Traversing of tables and chains
- Chapter 8. Saving and restoring large rule-sets
- Chapter 11. Iptables targets and jumps
- Chapter 5 Installing and Configuring VirtualCenter 2.0
- Chapter 16. Commercial products based on Linux, iptables and netfilter