Getting started with Emacs (2)

Source: Internet
Author: User
The previous section describes how to open and save files. This time, we will first introduce how to move the cursor in the document (the cursor is represented as a point in Emacs terminology ).
Although you can move the cursor with the used cursor moving key in Emacs, it does not conform to the design concept of Emacs "hand does not leave the main keyboard", so it designs a method for moving the cursor.
The simplest move is, of course, up and down, and the corresponding keys are c-P, C-N, C-B, c-F. To facilitate memory, remember that pnbf is the abbreviation of previous line, next line, backward, and forward. Try to practice it several times to ensure you are proficient.
The second step is page flip. You can usually use <Pagedown> and <Pageup>, but the shortcut keys of Emacs are c-V and M-V. Note that there is a new representation here, m-V: press <meta> and then press v. What is the <meta> key? For most PC keyboards, the <meta> key is the <alt> key. You can open a long article and try it. You can press c-h t to open the tutorial of Emacs for practice, so you don't have to worry about changing it accidentally, the turtoial you open is just a copy. Even if the disk is damaged and saved, the next time you open it, it will be a brand new version.
C-a and c-e can move the cursor to the beginning and end of a row, which is equivalent to <Home> and <End>.
If you replace the ctrl key of some commands with the Alt key, their functions will change: M-B, M-F, m-, m-e indicates moving one word forward, one word backward, to the first character of the current sentence, and to the last character of the current sentence. In this way, the ctrl key is used to move the cursor physically, in the unit of row and column, ALT shift is used to move the cursor logically, and words, sentences, and other meaningful units are used to move the cursor.
If you want to move several units at a time, you can add a numerical parameter to the command and run the c-u command, for example, C-U 8 C-N, which indicates moving down eight rows, c-u 10 m-e indicates moving back 10 sentences. However, the c-u parameter is special for C-V and M-V commands. It does not represent the number of pages that are up or down but the number of rows that are up or down. Note the difference with C-N. C-U 8 C-N indicates that the cursor moves down 8 rows, the screen may not necessarily scroll, and c-u 8 C-V, indicates that the screen is scrolled 8 rows. If the cursor is not rolled out of the screen, the cursor position remains unchanged.
As mentioned above, you can use C-g to interrupt the current command. In this case, when C-G does not work, you can press <ESC> three times to achieve the same purpose.
Next, we will introduce two commonly used but not very good operation commands, M-<and M->, because the <and> symbols are in, and. so in actual operation, press Alt + Shift +, and ALT + Shift + ., these two commands are used to move the cursor to the start and end positions of the file respectively.
After learning a lot of things, you can easily play some games that come with Emacs. They can all be found in the games in the Tools menu, if you know the name of the game, you can directly use the command to call it. Press M-X first, and then enter any valid command. If you want to play a snake, you can enter the snake command. In fact, all Emacs operations have the corresponding command name, including the preceding and the various shortcut keys to be introduced, such as C-x C-s to save the file. The corresponding command is save-buffer, you can type M-X and then input save-buffer to perform the same functions as pressing C-x C-S. This is useful when you forget the shortcut key. Similarly, if you remember the shortcut key but do not know the corresponding command name, you can press C-H c-k and then press the corresponding shortcut key to view the help. Remember, the Emacs help is very detailed. I printed an Emacs manual, covering more than 500 pages, covering every detail of Emacs operations.
The following describes how to undo, cut, copy, and paste operations similar to those in windows.
Undo is the simplest. The shortcut key is C-_. Similarly, because the _ symbol is in the Top Gear, You need to press the Shift key. If you think this is inconvenient, you can use C-x u, functions are the same. Similarly, you can add a numeric parameter to c-u before C-_ to cancel multiple steps at a time.
To select a region in Emacs, move the cursor to the start or end position of the region, press C-<SPC> or C-@ (the former may be occupied by the switched Input Method in windows, so only the latter can be used. Similarly, do not forget to press the Shift key and do not remind you later ), in this case, emacs prompts mark set and moves the cursor to the end position. Under normal circumstances, there will be no reflection on the screen indicating that a region is set. However, this region is selected.
In this case, you can kill the selected region by pressing C-W, which is equivalent to the cut operation in windows. In Emacs, the delete and kill words have different meanings, the former usually refers to the deletion, and can only be restored through the Undo operation, while the latter is equivalent to the cut, and can be restored through a certain method (Yank ). In addition, unlike traditional windows, the cut in Emacs is similar to the new office clipboard, which can store copied or cut items multiple times.
To restore the last kill content, you can press C-y and press it multiple times to execute the Yank last kill content multiple times, which is equivalent to sticking the same content multiple times in windows. If you want Yank to kill the content several times before, you can press the M-y key repeatedly.
To implement the same features as copying in Windows, you can press the M-W key after the selected area, it will put the selected content into the kill-ring so that later Yank will not kill the selected content.
With the above content, you can basically use Emacs as a tool similar to Windows notepad. We will continue to describe more advanced features later.

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.