Tuesday, October 6, 2009

Emacs Learn(1)


C-f     向右移动一个字符


C-b     向左移动一个字符







M-f     向右移动一个词【对中文是移动到下一个标点符号】


M-b     向左移动一个词【对中文是移动到上一个标点符号】







C-n     移动到下一行


C-p     移动到上一行







C-a     移动到行首


C-e     移动到行尾







M-a     移动到句首


M-e     移动到句尾






M-< (META 小于号)可以将光标移动到所有文字的最开头;M-> (META 大于号)可以将光标移动到所有文字的最末尾。


大部分的 Emacs 命令接受数字参数,并且对于多数命令而言,这些数字参数的作用是指定命令的重复次数。为一个命令指定数字参数(也就是重复次数)的方法是:先输入 C-u,然后输入数字作为参数,最后再输入命令。如果你有META (或EDIT 或 ALT)键,那么还有另一种办法:按住 META 键不放,然后输入数字。不过我们还是建议你用 C-u,因为它在任何终端机上都能用.
<Delback>    删除光标前的一个字符
C-d          删除光标后的一个字符

M-<Delback>  移除光标前的一个词
M-d          移除光标后的一个词

C-k          移除从光标到“行尾”间的字符
M-k          移除从光标到“句尾”间的字符

C-x C-f         寻找文件。
C-x C-s         保存文件。
C-x C-b         列出缓冲区。
C-x C-c         离开 Emacs。
C-x 1           关掉其它所有窗格,只保留一个。
C-x u           撤销。

The part below is copying from http://xahlee.org

Basic Keyboard Shortcuts

Open, Save, Close

Ctrl+x Ctrl+f
Open a new file
Ctrl+x Ctrl+s
Save file
Ctrl+x k
Close the current file

Moving Cursor

Use the arrow keys    , and HomeEnd,Page Up Page Down keys.
Ctrl+
Move cursor left by word.
Ctrl+
Move cursor right by word.
Ctrl+Home
Beginning of document.
Ctrl+End
End of document.

Deleting Text

Alt+d
Delete the next word
Alt+Backspace
Delete the previous word
Ctrl+k
Delete all characters from cursor to end of line

Copy Paste Undo

First pull the menu “Options‣C-x/C-c/C-v Cut and Paste (CUA)”, then pull the menu “Options‣Save Options”.
Ctrl+Space
Mark the starting point for copy/cut a text
Ctrl+c
Copy
Ctrl+x
Cut
Ctrl+v
Paste
Ctrl+x h
Select All
Ctrl+/
Undo. (To redo, type any character then do undo twice.)

Split Window

Ctrl+x 2
Split window into 2 panes
Ctrl+x 1
Make the cursor pane fill window
Ctrl+x o
Move cursor to the other pane

Searching Text

To search a word, press “Ctrl+s”, then type your search word, emacs will move the cursor to the location of the matched text as you type. Press “Ctrl+s” again to jump to the next occurrence, press “Ctrl+r” to jump to the previous occurrence.
Once you found what you are looking for, press the arrow key to cancel the search and leave your cursor there. To exit search and leave the cursor at its original place, press “Ctrl+g”.

Find and Replace Text

See advanced emacs tips.

Basic Principles of Emacs

General commands

Shortcut
Command Name
Description
Ctrl+g
keyboard-quit
Cancel a command or unfinished keyboard shortcut sequence
Alt+x
execute-extended-command
execute a command by name


No comments:

Post a Comment