The last time I talked about how to move the cursor in Emacs, this will show you how to edit text in Emacs.
The core function of any text editing software is of course editing text, Emacs is no exception, although it also has many other powerful skills, but can not be separated from text editing. Noisy, text editing it's just typing, the professional point is that we need to implement a WYSIWYG input method. There is no difference between typing and notepad in Emacs, as well as opening a file directly to the inside of the character, Chinese is OK. This is different from vim, we also need to know which mode we are in, otherwise we can not see how the screen reacts.
One, the file operation
Just now we said that editing the text is to open a file to the inside of the character, so the first thing we do is open a file.
C-x c-f Enter this command after you see a prompt "Find file:" In the Echo area, and then the path to my document, you need to enter the name of the file you are editing. Note that the input file name here can include a path, such as D:\text.txt, or a relative path. Also, we can use the Windows-style backslash "\" in Windows, and of course you can use a forward slash "/". If you enter a new path, the current path of Emacs jumps to the place you entered, (in effect, a new buffer is opened). If Emacs does not find the file you entered, it will automatically create a new file with the name you entered. Emacs also supports drag-and-drop, which means you can drag the file icon into Emacs to open it.
When you accidentally open a file, you can use the C-x c-v to change one, operation and C-x c-f, the difference is that Emacs processing in buffer is somewhat different.
C-x c-s This command is used to save the file, save is C-x c-w, these two are relatively simple, a look will.
Second, enter the text
In addition to some basic input methods, Emacs can also enter nonprinting characters, which are the preceding characters in the ASCII table.
Using C-q (n), where n represents an octal number, the symbol in the ASCII table corresponding to n is played.
There are Unicode characters such as Japanese ah Korean, using c-x 8 followed by the Unicode standard character name or code can output this mess. I believe there will be no idle bored to remember such a long list of numbers, and we have more advanced programs, (advertising time) when ... When.. When.. , now a grand launch of the Unicode character Super input tool-Sogou soft keyboard, save you memory a lot of 16 of the trouble, but also can input Chinese, it is home travel must be good products.
Iii. deletion of text
Emacs has more patterns to delete text than input.
Backspace, BACKSPACE, this comparison is not the tradition of the said.
Del Key, delete the character at the cursor, although this is also very common, but it violates the principle of Emacs, "Your hand does not have to leave the main keyboard area", so we use c-d instead.
M-d, this is used to delete a word (remember that the word in Chinese refers to two consecutive punctuation in the sentence, so if you are playing Chinese this key or less use, a bit less careful how long a sentence is missing). And it removes the word from the cursor's current position to the end of the word and leaves you with the first half of it.
Corresponding, delete the word before half can use, m-backspace.
M-k, delete a sentence, this is a little different in Chinese and English. In Chinese it will only be deleted until the full period, including the period. In English, it does not recognize '. ', '! ', these things, but the whole paragraph is deleted (the English section with two carriage return). As with m-d, it is also deleted from the cursor at the beginning. The corresponding deletion back is c-x Backspace.
C-k, deletes the current line from the cursor.
A more detailed example is as follows: (the text that is covered by the wide line is the part that uses the arrow to point to the deletion of the command, note the difference between English and Chinese)
Four, the Undo command
Operation is inevitably a mistake, Windows inside the CTRL + Z command is also very high frequency, but in Emacs Ctrl + Z will find the window minimized. In Emacs to achieve the revocation effect is c-/ , you can also use C-_ or c-x u , all three of which corresponds to the Undo command.
and Vim similar, the deletion of Emacs is also stored in a buffer, the equivalent of a clipboard, we can easily call up something to put in, this place I have not looked carefully, put it to later talk about.
above is to undo the action on the text, there is a more commonly used command c-g , this is used to undo the command, when you lose half of the command found the wrong can use it.
v. Miscellaneous commands
Some of the more fragmented commands are more commonly used, and, uh, should actually be put in the first chapter, here first.
Help command:
C-h t to bring up Emacs Tutorial.
c-h r to bring up Emacs Manual.
c-h k (command) , bring up the corresponding command help, such as C-h K c-n is to see the help of C-n.
Blank line:
Inserts a blank line,c-o . Delete empty lines c-x c-o Note that if there are many empty rows, the command will delete only one blank line, and only one will be deleted. These two commands are not exactly the same, inserting a blank line is actually inserting a carriage return line break, and the standard to delete the blank line is that the line what the text is not deleted, if we press c-o in the middle of a line of text, the content after the cursor will move to the next line, and then press C-x C-o But there is no response, because this line
Repeat command:
Oberzhang describes the two numeric parameters of the repeating command, there is a no numeric parameter. C-x z , the object of this command is the command that it loses in front of it, for example, press C-n First, then press C-x Z, repeat C-n once, and then we go down one line at a time by pressing Z, it is quite convenient.
Summary:
Keys |
Command |
Role |
C-x c-f |
Find-file |
Open File |
C-x c-v |
Find-alternate-file |
Open another file |
C-x c-s |
Save-buffer |
Save File |
C-x c-w |
Write-file |
Save File |
C-Q (N) |
Quoted-insert |
Insert character, n denotes the octal ASCII code of the character |
C-x 8 |
Ucs-insert |
inserting Unicode characters |
C-d |
Delete-char |
Remove the character at the cursor |
Backspace |
Delete-backward-char |
Delete cursor before character |
M-d |
Kill-word |
Delete a WORD from the cursor |
M-backspace |
Backward-kill-word |
Delete the word before the cursor |
C-k |
Kill-line |
Remove cursor as Forward |
M-k |
Kill-sentence |
Delete the cursor from the sentence |
C-x Backspace |
Backward-kill-sentence |
Delete cursor before sentence |
(none) |
Kill-paragraph |
Delete cursor from paragraph |
(none) |
Backward-kill-paragraph |
Delete cursor before paragraph |
c-/
|
Undo |
Revoke |
C-_ |
Undo |
Revoke |
C-x u |
Undo |
Revoke |
C-g |
Keyboard-quit |
Undo Command |
C-h T |
Help-with-tutorial |
Bring up Emacs Tutorial |
C-h R |
Info-emacs-manual |
Bring up Emacs Manual |
C-h k (command) |
Describe-key |
View the corresponding command help |
C-o |
Open-line |
Insert Blank Line |
C-x C-o |
Delete-blank-line |
Delete empty lines |
C-x Z |
Repeat |
Repeat the previous command |
Not to be continued ...
Emacs Tutorial (iii)