Emacs 常用快捷键总结

Keyboard shortcutsEffects
emacs -nw -Q不安装任何插件在命令行打开 Emacs
C-vforward one screen
M-vbackwards one screen
C-ltext around cursor to center of screen
M-x help-with-tutorial打开教程
C-x C-cend Emacs session

#Basic Cursor Control

Keyboard shortcutsEffects
C-pprevious line
C-nnext line
C-bbackward a character
C-fforward a character
M-bbackward a word
M-fforward a word
C-abeginning of line
C-eend of line
M-abeginning of sentence
M-eend of sentence
M-<beginning of whole text
M->end of whole text
C-u num commandrun command, use num as repeat-count; 注意 C-u 6 C-v 与其他命令的不同
C-gquit a partially entered command; 退出没有响应的命令
C-x 1kill all other windows

如果遇到暂时禁止执行的命令,按下 n 取消执行。

#Inserting and Deleting

Keyboard shortcutsEffects
<DEL>=BackSpacedelete character before current cursor
M-<DEL>kill word before cursor
C-ddelete next character after cursor
M-dkill next word after cursor
C-kkill from cursor to end of line
M-kkill from cursor to end of current sentence
C-emove to end of line
M-emove forward to end of sentence
C-<SPC>(<SPC>=space) move-cursor-to-somewhere C-w C-ykill random text, then yank to somewhere(like cut and paste)

killingdeleting 的区别:

  • killed text can be reinserted (at any position)
  • deleted things cannot be reinserted in this way, but you can undo a deletion

Reinsertion of killed text is called “yanking”.

#Undo

Keyboard shortcutsEffects
C-/undo a change to text(C-/ 不会撤销光标移动命令,滑动命令)

For C-/ Self-inserting characters are usually handled in group of up to 20.

Normally, C-/ undoes the changes made by one command; if you repeat C-/ several times in a row, each repetition undoes one more command.

#Files

Keyboard shortcutsEffects
C-x C-ffind a file
C-x C-ssave the file

#Buffers

Emacs stores each file’s text inside an object called a “buffer”.

Keyboard shortcutsEffects
C-x C-bList buffers
C-x b <BUFFER NAME>switch buffer
C-x b *Messages*see the messages

#Extending the command set

指的是两种行为:C-x,M-x。

Keyboard shortcutsEffects
C-x <one character>Character eXtend
M-x <a long name>Named command eXtend
C-zexit Emacs temporarily
fg or %emacs(exec in console)recover from C-z

#Auto save

#example.md#,这是一个自动保存的备份文件。

#Echo area

#Mode line

-:**– TUTORIAL 63% L736 (Fundamental)——–

  • 63% 表示当前文档的进度。如果来到文档底部会显示 Bot,来到文档顶部会显示 Top。
  • (Fundamental) 则是指编辑模式,

Major mode

Minor mode

#Searching

Keyboard shortcutsEffects
C-sstart search after cursor
C-rstart search before cursor

#Multiple windows

Keyboard shortcutsEffects
C-x 2create one more window(top+bottom)
C-x 3create one more window(left+right)
C-x oswitch to other windows(one by one)

#Multiple frames

Keyboard shortcutsEffects
C-x 5 2new frame

#Recursive editing levels

[(Fundamental)]

#Get help

Keyboard shortcutsEffects
C-h c C-poneline explanation
C-h k C-pexplanation with more details
C-h f <function name>describe a function
C-h v <variable name>describe a variable
C-h rread manual