Home > emacs > Learning Emacs – Ch 3 (Search)

Learning Emacs – Ch 3 (Search)

Chapter 3 – Search

A. Searching
1. C-s (isearch-forward) [Incremental search forward]
2. C-s C-s (isearch-repeat-forward) [Find the next occurance of the ]
3. C-r (isearch-backward) [Incremental search backward]
4. C-s C-s (isearch-repeat-backward) [Find the previous occurance of the ]
5. C-g [Cancel command, ie give up searching]
6. C-s C-w (isearch-yank-word ) [Start incremental search using the word that the cursor is on]
7. C-s C-y (isearch-yank-line) [Start incremental search using the text from the cursor position to the end of the line]

B. Search and Replace
1. M-x replace-string Enter “old-word” Enter “new-word” Enter [Replace all occurances of “old-word” with “new-word”]

2. To replace one word at a time.
M-< [move to the beginning of the buffer]
M-% (query-replace) [prompt Query replace: appears in the minibuffer]
Type the search string and press Enter. Emacs searchs for the first occurence of the string. It waits for user input which can be any off

i) Space or y – Replace searchstring with newstring and go to the next instance of the string.
ii) Del or n – Don’t replace; move to next instance.
iii) . (ie fullstop) – Replace the current instance and quit.
iv) , (ie comma) – Replace and let me see the result before moving on. (Press Space or y to move on.)
v) ! (ie exclaimation mark) – Replace all the rest and don’t ask.
vi) ^ (ie carrat) – Back up to the previous instance.
vii) Enter or q – Exit query-replace.
viii) E – Modify the replacement string.

source: “Learning GNU Emacs, 3rd Edition by Debra Cameron, James Elliott, Marc Loy. Copyright © 2005 O’Reilly Media, Inc. ISBN 0-596-00648-9”

Categories: emacs Tags:
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: