Learning Common Emacs Commands

This following list summarized some common used Emacs commands: 1. open file/close file - `C-x C-w`: save as to a new file - `C-x C-s`: save current file 2. copy and paste - `M-w`: copy - `C-y`: paste 3. split window - `C-l C-l` --> `C-x 2` --> `C-x o` to switch different window - `C-x 1`: close other windows to keep only one - `M-x make-frame or M-x delete-frame`: open or delete a new emacs window of a file - `C-x 3`: side by side splitting window 4. delete content and paragraphs - `C-d`: delete the next character after the cursor - `M-d`: delete next word - `C-k`: delete to the end of line - `M-k:` kill to the end of the current sentence 5. move to different location - `C-f or C-b`: move forward and backward by a character - `M-f or M-b`: move forward and backward by a word - `C-n or C-p`: move to next or previous line - `C-a or C-e`: move to the beginning or end of the line - `M-a or M-e`: move to the beginning or end of the sentence - `M-< or M->`: move the beginning or end of the file - `M-g g #:` go to specific line # 6. type the same words for multiple lines #### Add text - Start rectangle mode `C-x SPACE` - Move cursor to the previous (`p`) or next (`n`) line `C-p` / `C-n` - Target rectangle area `C-x r t` - Type text followed by `RET` to have text in selected lines #### Remove text - Start rectangle mode `C-x SPACE` - Move cursor to the previous (`p`) or next (`n`) line `C-p` / `C-n` - Move cursor forward (`f`) or backward (`b`) by character (`C`) or line (`M`). `M-f` / `M-b` - To remove text: `BACKSPACE` 7. search - `C-s`: search forward - `C-r`: search backward - keep typing the ctrl-s or ctrl-r to move the cursor. Press enter to end the search 8. move the cursor location - `C-u 8 C-f:` move forward by 8 characters 9. create new file - `C-x C-f`: new file 10. undo and redo - `C-x u` or C-_: undo 11. select all - `C-x h` 12. exit commands - `Esc-Esc-Esc`: 3 times Esc to exit commands 13. quit emacs - `C-x C-c`: quit 14. Help - `C-H ?`: display the help manual of emacs 15. Mark a selection area - C-space, C-@: to mark the beginning and end of selection. You can cut the selection area by C-w 16. replace with search - Alt+Shift+5: start the process of replace command - two queries will pop up: one to ask for the word to be replaced and the other for word to replace with - after that, the third query to ask you to type one of the following commands: image-20230131131555560