Emacas
I used to be a vim user for terminal coding. Not really a heavy user since I utilise Intellij for java development. But recently, I read the book called Structure and Interpretation of Computer Programs which explains the program in the deep level with Lisp
. The path of Lisp
learning arouses my interest Emacs, which provides EmacsLisp
for functionality extension. As all we know, the Emacs is characterized by its extensibility.
Emacs stands for “the extensible, customizable, self-documenting, real-time display editor”. In order to try its special magic, the first step is to get familiar with its shortcuts.
Here is the summary for the common shortcuts listed in the emacs tutorial in Emacs (can be invoked by C-h t
). A useful command is called C-h c
+ command to console the usage of the specific command. (For more detailed information, please use C-h k
instead of C-h c
)
C: stands for
Control
key. M: stands forEsc
key.
Note, my development environment is based on mac laptop. M is replaced forAlt
key on Windows computer.
Motion commands:
Key | Description |
---|---|
C-v |
Move forward one screenful |
M-v |
Move backward one screenful |
C-l |
Clear screen and redisplay all the text, moving the text around the cursor to the centre of the screen |
C-p |
Move to previous line |
C-n |
Move to next line |
C-b |
Move backward |
C-f |
Move forward |
M-b |
Move backward a word |
M-f |
Move forward a word |
C-a |
Move to the beginning of the line |
C-e |
Move to the tail of the line |
M-a |
Move to the beginnning of the sentence |
M-e |
Move to the tail of the sentence |
M-< |
Move to the beginning of the file |
M-> |
Move to the end of the file |
C-u + number + Operation |
Move forward/backward with specific number of lines/words/letters |
C-u
is valid for any opeartions. Even for character inputs. i.e.C-u
8 will insert 8 in the editor.
Frame Operations:
Many opeartons starts with
C-x
. Most of them are related with windows, files, buffers opeartions.The bottom line is called minibuffer.
Key | Description |
---|---|
C-g |
Discard commands |
C-x + C-c |
Exit Emacs |
C-x <number> |
Create some windows (i.e. kill all other windows) |
C-x C-f |
Find a file |
C-x C-s |
Save the file |
M-x make-frame |
Create a new frame |
M-x delete-frame |
Delete the selected frame |
Buffer Operations:
Emacs stores all file text into a object called buffer
Key | Description |
---|---|
C-x C-b |
List buffers |
C-x b <BufferName> |
Switch to specific buffer with buffer name |
C-x s |
Save some buffers |
C-z |
Suspend Emacs temporarily |
C-x o |
Switch to the other windows |
C-x k |
Kill the current buffer |
M-C-v |
Scroll the window in the other buffer |
Editor Operations:
Key | Description |
---|---|
<Delback> |
Delete the character before the cursor |
C-d |
Delete the character afte rthe cursor |
M-<Delback> |
Delete the word befor the cursor |
M-d |
Delete next word after the c |
C-k |
Kill from the cursor position to the end of the line |
M-k |
Kill to the end of current sentence |
C-@ /C-<SPC> C-w |
Kill the context between the two positions |
C-y |
Yank back the killed text. Reinset last killed text |
M-y |
Yank the previous killed text. |
C-/ / C-x u |
Undo previous with one/several command(s) |
M-x repl s<TAB> |
Replace one string with another in the buffer |
M-x recover-file |
Recover files from crashed computer |
M-x fundamental-mode |
Switch back to fundamental mode |
C-x f |
Set the width of margin |
C-s |
Search forward |
C-r |
Search backward |
In increment search mode, use
C-s
and<DEL>
to move back / forward for matched results.