Xah Lee, 2005, 2009, 2010-05-05, 2010-08-28
If you are a emacs beginner, see Emacs Basics.
Don't forget, all the basics such as copy, paste, open, save … are in the graphical user menus. The menu also shows you their keyboard shortcuts.
First, turn on the CUA mode, under the menu 〖Options▸C-x/C-c/C-v Cut and Paste (CUA)〗. The CUA mode will activate the following shortcuts:
Also, it will highlight when a region of a text is selected. And, when a text is selected, typing any text will automatically replace the current selection. Pressing the Backspace key will also delete the selection.
The emacs's Options menu. You can turn on standard copy and paste shortcuts called CUA mode. Mac screenshot
| Ctrl+x Ctrl+f | Open a new file |
| Ctrl+x Ctrl+s | Save file |
| Ctrl+x k | Close the current file |
Use the arrow keys ↑ ↓ ← →, and Home, End, 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. |
| Alt+d | Delete the next word |
| Alt+Backspace | Delete the previous word |
| Ctrl+k | Delete all characters from cursor to end of line |
First pull the menu 〖Options▸C-x/C-c/C-v Cut and Paste (CUA)〗, then pull the menu 〖Options▸Save Options〗.
| Ctrl+z | Undo. (To redo, type any character then do undo twice.) |
| Ctrl+c | Copy |
| Ctrl+x | Cut |
| Ctrl+v | Paste |
| Ctrl+x h | Select All |
| Ctrl+Space | Mark the starting point for copy/cut a text |
| 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 |
To search a word, press 【Ctrl+s】, then type your search text, 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 a 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】.
See advanced emacs tips.
In emacs, every keystroke actually executes a command. For example, when you type a key e, emacs actually runs the command “self-insert-command”. Any key or key combination sequence you press ultimately calls a command. There are about 3000 commands in emacs. Most commonly used commands have a keyboard shortcut, such as moving the cursor, opening file, copy paste, close a file, search text. To run a command by name, type 【Alt+x】 followed by the command name.
| Shortcut | Command Name | Description |
|---|---|---|
| 【Ctrl+g】 | keyboard-quit | Cancel a command in progress, or cancel unfinished keyboard keystroke sequence |
| 【Alt+x】 | execute-extended-command | execute a command by name |
If you know a command's name, you can find out its keyboard shortcut (if there is one).
If you know a keyboard shortcut, you can find out what command it calls.
The commands for these are “describe-key” and “describe-function”.
| Shortcut | Command Name | Description |
|---|---|---|
| 【Ctrl+h k】 | describe-key | Find the command name of a shortcut |
| 【Ctrl+h f】 | describe-function | Find the shortcut of a command |
In emacs, a selection of text is called “region”. Many commands acts on the selected text. Here are some examples of commands that act on the region.
Not all commands acts on region. Here are some commands that do not necessary need a region:
The above are just some examples. There are 3k commands out of the box.
blog comments powered by Disqus