Search and replace for Emacs

Source: Internet
Author: User
Tags isearch

Find and replace are features that are indispensable to any editor.

Input >> Notice >> input >> quit >> output

Active region, or cursor point to end.

Marked files in dired.

Active region >> c-r >> php >> RET >> c-g OR ESC ESC ESC

What is recursive editing state???

Recursive editing state, simply said that you in the process of looking for replacements suddenly found that need to modify something, but do not want to directly exit the search and replace, then Emacs provides a temporary editing state can let you first think of things, and when you have finished can also go back to find the replacement state, This temporary state is called recursive editing state.

Emacs divides the search into four large categories: Simple lookup, incremental lookup, phrase lookup, and regular lookup. Each of the four methods have characteristics, the scope of application is also different, we are familiar with the needs of one or two.

Mark ring kill ring Search ring

1. C-s >> s >> c-s OR c-r

2. C-s >> s >> m-c >> c-s OR c-r

3. C-s >> C-j

4. C-s c-s OR c-r c-r

C-s, Mini buffer will appear i-search, enter the word you want to find, as you enter the character increase increment highlight, find the word you want, type enter--c-s command to toggle the position of the word

C-s Isearch-forward starts from the cursor position (toward the end of the file) increments the lookup

C-r Isearch-backward from the cursor position (toward the head of the file) increments the lookup

C-s C-w A word starting at the cursor position as a lookup string

C-s c-y from the cursor position to the end of the line as a lookup string

Return Exit Lookup

C-g keyboard-quit Cancel Incremental lookup (press two times)

M-s w ret words ret (word-search-forward)

M-s W c-r ret words ret (word-search-backward)

------------------------------------

I-search

I-search-backward

Search

Word I-search

Word Search

I-search-regexp

I-search-backward-regexp??? It's not going to work.

Two. Replace

Note: Is the forward lookup replacement

M-x replace-string

M-x Replace-regexp

m-% Query-replace

c-m-% Query-replace-regexp

Search and replace for Emacs

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.