Use Emacs (1)

Source: Internet
Author: User
  1. Each Command in Emacs has a command name, which is the name of the lisp function corresponding to the command. In Emacs, you can configure shortcuts for these commands to quickly call commands.
  2. There are two methods to run commands using Emacs: (1). use ctrl (2). Use meta. All Emacs commands can be expressed by the meta key. If the meta key is not displayed on the keyboard, the Alt key or ESC key can be used instead. Common Emacs commands usually have a shortcut key to connect to them. The shortcut key usually starts with CTRL (c-X c-c ). If you want to use the meta key to express the same effect as "Ctrl-x Ctrl-c", use "M-x save-Buffers-kill-Emacs ". The meta key can be used to complete Emacs. To use the completion function of Emacs, type some strings, and then press tab, space, or? Key.
    (1). Tab key: Fill in the words as much as possible.
    (2). Space key: Fill in the words before the separator.
    (3 ).? : List all possible completion options.
  3. Since all commands in Emacs have a command name (the function name of the lisp function), we can use the "M-x command name" to call all commands in Emacs.

* Basic cursor control

  1. C-V: Flip-down, which has the same effect as Pagedown (V-> vertical)
  2. M-V: screen up, same as Pageup
  3. C-l: Re-paint the screen and place the row where the cursor is located in the center of the screen
  4. C-B: move the cursor one cell forward (B-> backward)
  5. C-F: move the cursor backward (F-> forward)
  6. C-P: move the cursor One Line Forward (p-> previous)
  7. C-N: move the cursor One Line Backward (n-> next)
  8. M-B: move the cursor forward a word
  9. M-F: Move a word behind the cursor
  10. C-A: move the cursor to the beginning of the line
  11. C-E: move the cursor to the end of the row
  12. M-<: move the cursor to the beginning of the article (Note: shift is required for the "<" input, which is Alt + Shift + <)
  13. M->: move the cursor to the end of the article.
  14. C-u: PASS Parameters to the command. For example, "C-U 2 c-d" indicates that two characters are deleted.
  15. M-x goto-line n ret: adjusted to row n

* Edit command

  1. C-d: delete a character after the cursor
  2. C-K: Delete the character from the cursor to the end of the line (k-> killl)
  3. C-x u: undo)
  4. C-SPC, C-@, M-x set-mark-command: Set mark
  5. C-x H: set the entire buffer zone as a region.
  6. C-W: Delete the text of the region and place it in the yanking ring. A region refers to the text between Mark and point (the position of the cursor is called point ).
  7. M-W: copy the region to the yanking ring.
  8. C-Y: insert the last region of the yanking ring into the current buffer zone.
  9. M-J: Press enter and generate appropriate indentation for the next line
  10. M-M: move the cursor to the first non-blank character in the current row
  11. M-;: generate general comments
  12. M-x comment-region: comment out the block
  13. M-x kill-Comment: eliminates comments

* Search and replace

  1. C-S: Search backward. The cursor stops at the first matched string. Once again, the C-s will continue to search for the next matched string. If you want to stop the search, use C-g, and the cursor will return to the start position of the search.
  2. C-r: Forward search
  3. M-x replace-string: replace

* File Operations

  1. C-x C-F: Open the file. If the file does not exist, create
  2. C-x C-S: Save the file. During the first disk storage, emacs will rename the file for backup. A heavy command is usually followed by a "~" after the original file name. Character. To disable automatic backup of Emacs, use M-x Customize-variable <return> make-backup-files <return>
  3. C-x C-W: Save the file"
  4. C-x C-V: open a new file and close the current buffer.
  5. C-X c-r: open a file in read-only mode
  6. C-x I: insert the file to the current position of the cursor

* Buffer zone

  1. Emacs places each edited file in a buffer. Each time a file is opened, emacs opens a buffer inside it to store the data of the opened file. The ESC command can be used to exit the opened small buffer zone, such as the command prompt pane.
  2. C-x C-B: list all current buffers (B-> buffer)
  3. C-x B buffer name: switch to the specified buffer (for example, C-x B m <tab>: switch to the buffer starting with m)
  4. C-x s: save all the buffers in Emacs (S-> Save)
  5. C-X right: switch to the next Buffer
  6. C-x left: switch to the previous Buffer
  7. C-x C-C: Exit Emacs and ask whether the user saves
  8. C-x K: Disable the buffer.
  9. C-Z: suspends Emacs and returns to shell without exiting Emacs. Then, we can use the % Emacs or fg command to return to Emacs


* Window

Emacs can have multiple panes with different texts displayed in each pane.

  1. C-x 0: Close the window where the cursor is located
  2. C-x 1: Keep the pane where the cursor is located, extend it to the entire screen, and turn off all other panes.
  3. C-x 2: horizontal split current window
  4. C-x 3: vertically split the current window
  5. C-x O: switch in the Emacs pane (o-> other)
  6. C-m-V: Scroll down the lower pane. We usually use the lower pane for reference, but do not want to switch the cursor to the next pane.


* Help

  1. C-h c shortcut key: a brief description of the shortcut key
  2. C-h k shortcut key: displays the command name corresponding to the shortcut key and its details
  3. C-H a keyword: displays the command containing the specified keyword
  4. C-H I: View info documentation


* Run the shell command in Emacs.

  1. M -! Cmd ret: open a window named "* shell command output *" and display the execution result of the command. Press the "C-x 1" key combination to close the window. Because the shell command output is in an editing buffer, We can edit and save it.
  2. M-| cmd RET: run the shell command and use the area selected in the editing window as the input of the shell command, then, you can choose whether to use the shell command output to replace the selected area in the editing window.
  3. C-u m -! Cmd ret: execute a shell command and place its output to the position of the cursor in the editing area, instead of outputting it to the "shell command output" window.
  4. M-x shell: run a sub-shell, which corresponds to a buffer named "* shell *" in Emacs. Then, we can run the shell command interactively.
  5. M-x term: run a sub-shell, which corresponds to a buffer zone named "* Terminal *" in Emacs. The sub-shell obtained using this command is a complete shell simulation, which is no different from the direct operation in shell.
  6. M-x eshell: Run Emacs shell. This shell is a self-implemented shell by Emacs, and the preceding shell is a shell program (for example,/bin/CSH) in the system ). We can set the shell-file-name variable to set the default shell used by Emacs.

* Dired Function

  1. The Dired (directory Editor) function of Emacs enables the Emacs buffer to display the directory list and enter the subdirectories of the directory. The Dired buffer is read-only and cannot be modified.
  2. C-x D: Enter Dired

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.