Getting started with Emacs (3)

Source: Internet
Author: User

Through the first two articles, you can use Emacs as a better-notepad. What we want to learn today is the powerful search function in Emacs.
By default, emacs uses a special "incremental search" function, although it is very different from our common search methods in terms of Operation habits, however, it is very convenient to get used to it.
To enable Emacs to start searching, you can press C-S or C-R. The former is to search from the cursor position, and the latter is to search forward. Take C-s as an example. After pressing C-S, emacs prompts I-Search: In minibuffer. Then you can enter the keyword to search, now, we recommend that you slow down your input to see how Emacs executes your search request.
For example, if you want to search for the word "Search" and enter S, emacs will move the cursor to the last s letter. If you suspend the input for a while, emacs will highlight all s letters. Enter E. Then, emacs finds the nearest se letter combination. Enter it until Emacs finds the content you are looking for and then press enter to end the search.
During the search process, you can repeatedly press C-S or c-r to perform backward or forward search. If you have found a matched content and press the Enter key to complete the search, if you want to continue searching for this content, you only need to press C-S or c-r twice. The first click is used to activate the search function, and the second click is used to continue searching.
When you enter a search keyword, If you accidentally enter an error, press the <del> key to clear the previous character. Note that in the Emacs terminology, <del> A key is generally referred to as the <backspace> key, And the <Delete> key represents the <Delete> or <del> key on our Keyboard.
When entering keywords, there is also a detailed problem. If all the keywords you enter are English letters, emacs will perform a case-insensitive search. However, if the entered keywords contain uppercase letters, emacs will perform case-sensitive searches. In addition, you can use the M-C shortcut key to switch the word-sensitive mode during the search process. You can use it to forcibly specify whether the word is case sensitive.
If you do not want to use the incremental search function of Emacs, you can also enable Emacs to perform a traditional search. Press C-S or C-R and press a enter key, in this case, emacs performs a non-incremental search. You can enter your keywords and press the Enter key to perform the search.
The following describes more powerful regular expression search functions. You can press C-m-S or C-m-R to start the forward or reverse Regular Expression search function. emacs will prompt Regexp I-search in minibuffer :, then you can enter the regular expression to be matched.
Many control symbols can be used in regular expressions. Here I will select several common ones for a brief introduction. A more comprehensive and complex explanation can be found in the Emacs manual.
'.' (Period): The period in a regular expression can be used to match any character. For example, the regular expression 'a. B 'can match ABB, ACB, ADB... A string of three characters starting with a and ending with B.
'*': The * sign in the regular expression can be used to repeat the previous character 0 or multiple times. For example, 'ff * 'can match one or more strings connected to F.
'+': The "+" and "*" functions basically the same in a regular expression. The difference is that it indicates repeating the character before it once or multiple times, therefore, we can see that the regular expression 'ff * 'is equivalent to 'f + '.
The regular expression syntax of Emacs is very complex and powerful. Please read the Emacs manual to learn them comprehensively, which will bring great convenience to your work. As an introductory tutorial, I will not give a more comprehensive description here.

-----------

Note: I am about to be killed by this Article. First, I cannot post the article. The system does not say that the banned words in my article are unacceptable and I can hardly find them out, it's the word "great () convenient" at the end of the article. I didn't write that word at first.
It's hard to paste it. Well, the word <Delete> has changed to a strikethrough line. You know, I have changed the number greater than or less to the corresponding HTML code. No way, I changed it once again. I don't know how many times I have pasted this article. It's so hard!

 

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.