Emacs Easy Tutorial

Source: Internet
Author: User
Tags save file

Emacs Easy Tutorial Read:

Command:

$emacs

After entering, enter:

C-h T

Here, c-h means holding down the [Ctrl] key while pressing H

#######

20090620

Exit

Enter "C-x c-c"

Undo

Enter "C-x u"

or enter "C-_"

Here, "c-_" better input some (like c--also line), but some keyboard above "_" can only enter "C-x U", undo action can be carried out 20 times.

* PAGE UP:

Enter "M-v"

Here, the right-handed m seems not good to make?

* PAGE DOWN:

Enter "C-v"

* Refresh screen:

Enter "C-l"

Here, L is not 1, and after execution the cursor and the corresponding text run to the middle of the screen.

* Basic Move cursor:

C-f moves forward one character.

C-b moves backward one character.

M-f moves forward one word.

M-b moves backward one word.

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 moves to the end of the line.

M-a moves forward to the beginning of the sentence, which may be less than one line or line.

The m-e moves backwards to the end of the sentence and may be less than one line or row.

From the above commands, M is a language-related control key, followed by the basic unit C. The feature of Emacs is that when you move the cursor, if the cursor is outside the screen (up or down), the cursor and nearby text are immediately centered on the screen.

* Repeat a certain number of actions:

Enter "C-u < numbers > < commands you want to repeat or characters you enter >"

Over here

C-u < number > is a "prefix", the number is the number of times to execute subsequent commands, for example, "C-u 8 C-p" represents the forward 8 rows.

Most commands repeat this "prefix", but some special commands are not, and will be encountered later.

C-v and M-v plus this number represent how many rows of the screen are moved rather than how many pages are turned.

* Terminates the command that is now executing:

Enter "C-g"

* Turn off other windows to display only the cursor window:

Enter "C-x 1"

In the Multi-window, this will turn off all the windows, only one window is displayed.

* Let the cursor line run to the top of the screen:

Enter "C-u 0 c-l"

* View C-f's documentation explanation:

Enter "C-h k c-f"

This will open a new window to show the interpretation of the command (C-F), similar to the other commands explained.

* Basic Delete operation:

<Delback> Delete the characters in front of the cursor, no more pasting

M-<delback> Remove the word in front of the cursor

C-d Delete the character following the cursor,

M-d Remove the word that follows the cursor

C-k Remove the content from the cursor position to the end of the line, and then paste

M-k drop to the end of the current sentence

# # #阅读至386行

###########

20090621

*kill the contents of a block:

1) Enter "c-<spc>" or "[email protected]" At one end of the block.

This will set a tag.

2) Enter "C-w" at the other end of the block.

At this point, the block (the part between the ends) will be deleted.

The difference between kill and delete is that the kill part can be pasted up, like clipping.

*kill the cursor of the current line and the part after the cursor:

Enter "C-k"

This will delete the corresponding content including the cursor, and then press "C-k" to remove the newline symbol.

* Paste the text that was deleted by the recent Kill method:

Enter "C-y"

* Paste the text of a kill delete several times before:

1) Enter "C-y" first

This will paste the latest kill deleted text back.

2) Multiple input "m-y"

This will continue to replace the text you have just pasted (looping) with the previously deleted text, so that it continues until you paste the previously deleted text.

* Open a file Yourfilename:

Under command line: $emacs yourfilename

or emacs Input: "C-x c-f <yourfilename>"

This way, if the file name does not exist, then create a new one, the second command "C-x c-f" after you are prompted to enter the path of the file to open, the current file is not saved and will not be prompted but the exit will be prompted when you just loaded the new file before the saved file is saved, No new open a file emacs will create a new buffer to store the file.

* Save a file:

Enter "C-x c-s".

This saves the file and prompts if it is not saved. If you do not save the file, the bottom of the prompt line with * indicates not saved.

* See the list of all the buffer in Emacs:

Enter "C-x c-b"

This displays a list of buffer, each showing the name of the open file.

* Switch to the appropriate buffer list:

Enter "C-x b <buffer List name >"

Here, "C-x B" after the direct input buffer list name, than "C-x c-f" way to switch a lot easier.

* Save Buffer contents:

Enter "C-x S"

This way, after you enter "C-x S", you will be asked in turn whether the unsaved buffer files you have changed are saved, and you just need to answer them.

######### #阅读至650行

#######

* Replace string:

1) Enter "M-x"

This prompts you to enter a replacement command that can be used <TAB> auto-complete.

2) Enter "Repl s<tab>"

Here is the use of <TAB> to automatically complete the command, if not fill the full return, the command is the only line.

3) Enter "<Return>"

After carriage return <Return>, you are prompted to enter the character to be replaced.

4) Enter "characters to replace"

5) Enter "<Return>"

After carriage return <Return>, you are prompted to enter the character to be replaced.

6) Enter "characters to be replaced"

7) Enter "<Return>"

* Auto-Save function:

Emacs provides auto-save functionality, such as when you modify the "hello.c" file, it generates a "#hello. C #" file (called AutoSave file), and periodically writes the latest data to this file, and Emacs deletes the file when you save it. You can use this file to recover when your machine is hung up.

* Recover files with auto save file:

Assuming that the file hello.c is automatically saved, the #hello.c# recovery step is as follows:

1) Enter "M-x"

This prompts you to enter the recovery command, which can be used <TAB> auto-complete.

2) Enter "Recover<tab>"

This will automatically fill the Recover-file

3) Enter "<Return>"

4) Enter "HELLO.C"

This is the name of the file to be restored, not the #hello.c#

5) Enter "Yes"

Here, you are prompted to enter "Yes" to confirm the recovery.

* Convert main display mode:

Assuming the conversion to fundamental mode, the steps are as follows:

1) Enter "M-x"

2) Enter "Fundamental<tab>"

The name of the pattern is entered here, using <TAB> Auto-completion.

3) Enter "<Return>"

This transforms the pattern into a fundatmental mode. There are several different main modes in Emacs, the different types of text they are used to edit, the name of the main mode currently in the top of the status bar at the bottom, and a slightly different command behavior in different main modes. For example, when the text mode is m-f and m-b, the comma is also regarded as part of the word, while the Fundatmental mode treats comma as a separator symbol and so on, but the command generally behaves the same.

* View the Help document in your current main mode:

Enter "C-h m"

* Turn off Secondary mode:

Assuming that the Auto Fill mode is turned off, the steps are as follows:

1) Enter "M-x"

2) Enter "Auto-fill-mode"

3) Enter "<Return>"

After the carriage return, the Auto-fill-mode mode (toggle) is turned on or off, which is very useful in human-language text editing, when on, when the number of words is too high, It will automatically insert a newline instead of a continuation symbol at the end of the last word (note that the whole word must be in a space).

Since there are major patterns, and of course there are secondary patterns, the secondary mode does not replace the main mode, they are just something like "options" to slightly change the behavior of the main mode, can be independent of the main mode or other secondary mode to open and close.

* Change the padding of a row (not understood?):

Assuming that the change is 20, enter the following:

1) Enter "C-u 2 0 c-x F"

2) Enter "M-q"

This setting after Auto-fill-mode no use, want to re-re-fill, to enter M-Q in the current paragraph. You will see that the segment becomes 20 characters per line.

######### #阅读至850行

#######

Search

Suppose you search for "cursor", the steps are as follows:

1) Enter "C-s"

At this point, a prompt will appear at the bottom prompting you to enter the string to search for

2) Enter "< The string you want to search >"

At this time, you will find that with your input, Emacs will highlight the corresponding match and the cursor jumps back to the nearest match, when you search for the deletion of a character, Emacs jumps to the last cursor search word (less one character), when the deletion of empty, The cursor should jump back to the point where you first searched.

3) Enter "C-s"

This will jump the cursor to the next matching string.

4) Enter "<Return>"

After a carriage return, the search ends (the next two consecutive "C-s" will continue to search for the last search string).

Note that some systems interpret "c-s" as a lock screen , and instead of sending commands to Emacs, you can press C-Q to stop the lock screen and view the spontaneous Entry to Incremental Search section of the document.

* Reverse Search:

Method with "Search" method, but changed "C-s" to "C-r"

* Set the current cursor and line to the first line in the screen:

Enter "C-u 0 c-l"

Here is the lowercase l not 1.

* Split window:

Enter "C-x 2"

This will horizontally divide the current window into two, which can display different files in two windows.

* Cursor in the current window, to the bottom of the window page:

Enter "C-m-v"

or enter "<Esc> c-v"

Here, Emacs is horizontally divided into two window states, the current cursor in the window above, and then this command will page the following window, if the cursor in the following window will be the window to the above page; Note If you do not have the M control key (that is, alt) then you have to implement this function with a second method, Enter <Esc> re-c-v first.

* Switch between the top and bottom two windows of a split:

Enter "C-x o"

This toggles the cursor between the top and bottom two windows.

* Split one window to load another file:

Enter "C-x 4 c-f < your file name >"

* When you are at recursive edit level, you are not able to use C-g to cancel the order, then you need to use <Esc><Esc><Esc> (or more) to cancel, This pattern is said to enclose the pattern in square brackets, for example [(fundamental.)]. Alternative (fundamental) but actually , I don't think so.

######### #阅读至995行

#######

* How to get more help:

Enter "C-h?"

or enter "M-x help <Return>"

Generally with the first, if the first one is not good, use the second,<return> to indicate the carriage return.

* To view a command key or simple command order Help:

Suppose you look at C-p information:

Input: "C-h C c-p"

Here, a brief message describing the command (C-P) is displayed. The key is to enter "C-h C" before entering the command.

* See a command key or command order for detailed help:

Suppose you look at C-p information:

Input: "C-h k c-p"

Details of the command (C-P) are displayed here. The key is to enter "C-h K" and then enter the command.

######### #阅读至1050行

#######

20090808

* Find the function of a function:

Enter "C-h F"

Then enter a specific Emacs function.

* List Partial matches:

Enter "C-h a"

After that, enter a word that lists all the commands that contain the word (the META key is aroused)

* Online Info Brochure:

Enter "C-h i"

This will open info if you view emacs input "M emacs", if you do not know what to do, then enter '? ' You can display some basic operations for info.

Source: http://blog.chinaunix.net/uid-9525959-id-2001558.html

Emacs Easy Tutorial

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.