Emacs is a powerful and extensible text editor used in Unix-like operating systems. This cheat sheet covers essential commands for creating, editing, and navigating text files within the Emacs environment.
Introduction:
Emacs is known for its extensive features and customization options. It provides a wide range of commands and shortcuts for efficient text editing, making it a popular choice among developers and power users.
Basic Commands:
Command
Description
emacs [file]
Open or create a file for editing.
C-x C-f [file]
Open or create a file using key sequences.
C-x C-s
Save changes to the current file.
C-x C-c
Exit Emacs. If changes are made, it will prompt to save.
Editing Text:
Command
Description
C-x u
Undo the last action.
C-/
Another way to undo the last action.
C-space
Set the mark to start selecting text.
C-w
Cut the selected text (after setting the mark).
M-w
Copy the selected text (after setting the mark).
C-y
Paste the cut or copied text.
Navigation:
Command
Description
C-f
Move forward one character.
C-b
Move backward one character.
M-f
Move forward one word.
M-b
Move backward one word.
C-a
Move to the beginning of the line.
C-e
Move to the end of the line.
Searching and Replacing:
Command
Description
C-s
Search for text in the file.
C-r
Reverse search for text in the file.
M-%
Replace text in the file.
Cut, Copy, and Paste:
Command
Description
C-k
Cut text from the cursor position to the end of the line.
M-k
Cut text from the cursor position to the end of the sentence.
C-y
Paste the cut or copied text.
Miscellaneous:
Command
Description
C-g
Cancel the current command.
C-x u
Undo the last command.
C-h t
Open the Emacs tutorial.
C-h r
Open the Emacs manual.
Conclusion
Emacs is a feature-rich and extensible text editor with a vast array of commands. This cheat sheet covers essential commands for creating, editing, and navigating text files within the Emacs environment. Whether you are a developer or a power user, mastering these commands will enhance your efficiency in text editing using Emacs.