Emacs Tutorial Learning

Source: Internet
Author: User
Tags save file

First, start the study manual
1) Enter Emacs,help---Emacs Tutorial
2) Enter Emacs,c-h t

Second, learn to cheat
1) Page view shortcut key

C-v move forward one screen
M-v move backward one screen
C-L REDRAW the screen and place the line of the cursor in the center of the screen ( control-l, not control-1)


2) Cursor Movement shortcut key

f  represents  Forward (forward) 
b represents Backward (fallback)
n represent next (next line)
Span class= "PLN" >p represents Previous (previous row)

c-f     move one character to the right
c-b     move one character to the left
m-f      move right one word "to Chinese is move to next punctuation"
m- b     move left one word "to Chinese is move to previous punctuation"


C-n moves to the next line
C-p moves to the previous line
C-a moves to the beginning of the line
C-e move to end of line


M-a moves to the beginning of the sentence
M-e moves to the end of the sentence

M-< move to file header

Move to end of file M

3) use of prefix parameters
Most of the Emacs commands accept numeric parameters, and for most commands, the function of these numeric parameters is to specify the number of repetitions of the command. Specify a number parameter (that is, the number of repetitions) for a command by first entering C-u, then entering the number as the parameter, and then entering the command. This numerical parameter is also known as
"prefix parameter" means that the parameter is entered before the command that uses it. As shown below:

C-u 8 C-f moves forward 8 characters

Note: C-v and m-v are another type of exception. When given a parameter, they will scroll through the "Number of rows" you specify, rather than "number of screens." For example, C-u 8 c-v Scrolls the screen down by 8 lines instead of the 8 screen.

4) workaround when EMACS loses its response
If Emacs loses its response to your command, you can use the

C-g

To safely terminate this command.
C-g can also terminate a command that has been executed too long.
C-g can also cancel numeric parameters and enter only half of the commands.

5) Order Explanation

C-h k

Back to the command you want to explain, like,

C-h k C-f


6) Space operation
Emacs can have more than one pane, and each pane displays different text.

C-x 1 keeps only one pane (that is, all other panes are turned off)

7) Delete and remove (kill) actions

<Delback>Delete a character before the cursor
c-d               delete a character after the cursor

m-<delback>  removal A word before the cursor
m-d                remove A word after the cursor

c-k          remove from cursor to "end of line" character
m-k          remove

Delete area contents
First move the cursor to one end of the area you want to remove, and then press

c[email protected] or C-SPC

(any one can, SPC refers to the space) "Note that C-SPC is often set by the Chinese user Input method hotkey, if so, C-SPC is intercepted by the system and no
The method is passed to Emacs, so it is recommended to use [email protected]. , then move the cursor to the other end, and then press

C-w

You can remove all the text that is located between these two points.

8) The difference between removing (kill) and deleting (delete)
The difference between "remove" and "delete" is that what is removed can be found and deleted.
"In fact, the removal of things, although it seems to" disappear ", but is actually recorded by Emacs, so you can also find back, while the deleted things may still be in memory, but has been" abandoned "by Emacs, so can not find back. "Reinsert the removed text is called recall (Yank)." In general, those commands that may eliminate a lot of text will record the erased text (they are set to be "recalled"), while those that eliminate only one character
Or just eliminate blank commands and not record what is eliminated (naturally you can't recall).

9) Recall (yanking)
The recall order was

C-y

M-y

It will insert the last text you removed at the cursor position.
If you have pressed several c-k at a time, all the removed rows are stored together, so long as a c-y can recall them.

C-y can recall the most recent removal, how do I recall what was removed a few times before? Of course they are not lost, you can use m-y to recall them. After recalling the recently removed text with c-y, you can recall the contents of the previous removal by pressing M-y, and then press the m-y again to recall the last time ... Use m-y continuously until you find what you want to recall, then do nothing and continue editing.
If you press m-y many times consecutively, you may go back to the starting point, which is the recently removed text.
"This is actually a ring. 】

10) undo (undo)

C-x u


11) file operation

C-x C-F Looking for a file

C-x C-s to store this file

12) buffers (buffer)
Emacs places the files in each edit in a place called buffer. In each search for a file, Emacs creates a buffer within it. Use the following command to list all current buffers:

C-x C-b lists buffers

No matter how many buffers exist, there can be only one "current" buffer at any time, which is what you are editing. if you want to edit the other buffers, you must "toggle" the past. As I said above, with

C-x C-f

is a way. But there is one more simple way to do it.

C-x B

For this command, you must enter the name of the buffer.

If you have more than one buffer to save, use the following command

C-x s save multiple buffers

13) Command Set extension
Emacs's commands are like the stars in the sky, and the numbers are countless. It is obviously impossible to match them to the CONTROL and Meta key combinations. Emacs uses the extended (eXtend) command to solve this problem, and the extended command has two flavors:

C-x character extension. C-x then enter another character or key combination.
M-x command name extension. M-x then enter a command name.


+) suspend Emacs in Shell
c-z will "hang" Emacs, that is, it will return to the shell without exiting Emacs. In a common shell, you can usually use the "FG" or "%emacs" command to
Time to return to Emacs.

15) Fast input for string substitution

M-x repl s<Return>


16) Auto-Save and crash recovery
Automatically save the file's filename has a "#" character, such as the file you are editing is called "hello.c", then its auto-save file is called "#hello. C #". This file will be deleted by Emacs after the normal disk.
Once the system crashes
After rebooting the system, open the original file such as hello.c, then enter

M-x Recover file<Return>

To restore your auto-save file.

17) echo Zone (Echo area)
The Echo area is located on the bottom line of the screen.

18) status bar (mode line)
The line that is directly above the Echo area is called the status bar. Some information is displayed on the status bar, such as:
--:* * tutorial.cn (fundamental)--l670--54%----------------

19) Main Mode
The main mode of Emacs is a myriad of. There is a way to edit the code of the program, such as Lisp, or to edit various natural language texts, such as the text mode. In any case, only one main mode can be applied, and its name will be displayed on the status bar, where the "fundamental" is now displayed.
The main mode usually changes the behavior of some commands. For example, you can add a comment with the same command, regardless of the programming code of the language you are editing. However, the syntax of annotations in different languages tends to be different, when different main patterns add comments using their own different syntax rules. The main mode is all available
To use M-x to start the extended command,

M-x Fundamental-mode

You can switch to fundamental mode.


20) Search

C-s forward Search
C-R Backward search

In an incremental search, Emacs tries to jump to where the search target appears. To jump to the next hit position, press C-s once more. If the target is not found, Emacs beeps and tells you that the search failed. Throughout the process, you can use C-G to terminate the search. "You'll find that C-G will let the cursor go back to where the search started, and <Return> will let the cursor stay on the search results, which is a useful feature." 】

21) Multi-pane operation

C-x 2 divides the screen into two panes and the cursor is in the previous pane
C-M-v scroll down the lower pane
C-M-S-v scroll up below the pane

C-x o move the cursor to a different pane, which you can use to traverse all panes

C-x 1 retains only the currently edited pane

22) The most common departure command

ESC ESC ESC left

Emacs Tutorial Learning

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.