Here are some of the most important commands that are used in emacs.
Starting, Exiting, Reading and Writing Files in emacs
Command | Description |
---|---|
emacs myfile | Start emacs and edit myfile |
Ctl-x i | Insert prompted for file at current position |
Ctl-x s | Write out the file keeping current name |
Ctl-x Ctl-w | Write out the file giving a new name when prompted |
Ctl-x Ctl-s | Write out all files currently being worked on and exit |
Ctl-x Ctl-c | Exit after being prompted if there any unwritten modified files |
Changing Position in emacs
Command | Description |
---|---|
arrow keys | Use the arrow keys for up, down, left and right; or: |
Ctl-n | One line down |
Ctl-p | One line up |
Ctl-f | One character left |
Ctl-b | One character right |
Ctl-a | Move to beginning of line |
Ctl-e | Move to end of line |
M-f | Move to beginning of next word |
M-b | Move back to beginning of preceding word |
M-< | Move to beginning of file |
M-x goto-line n | Move to line n |
M-> | Move to end of file |
Ctl-v or PageDown | Move forward one page |
M-v or PageUp | Move backward one page |
Ctl-l | Refresh and center screen |
Searching for Text in emacs
Command | Description |
---|---|
Ctl-s | Search forward for prompted for pattern, or for next pattern |
Ctl-r | Search backwards for prompted for pattern, or for next pattern |
Changing, Adding and Deleting Text in emacs
Command | Description |
---|---|
Ctl-o | Insert a blank line |
Ctl-d | Delete character at current position |
Ctl-k | Delete the rest of the current line |
Ctl-_ or Ctl-x u | Undo the previous operation |
Ctl-space | Mark the beginning of the selected region; the end will be at the cursor position |
Ctl-w | Yank (cut) the current marked region and put it in buffer |
Ctl-y | Paste at the current position the yanked line or lines from the buffer |