Basic Emacs Commands
Starting Emacs
Emacs is flexible and widely-used text editor which is supported on the GL systems. To start the text editor, type the command emacs at the Linux command prompt.
You may also specify a file to open or create on the command line. For example, the command emacs example.cpp starts Emacs and loads the file example.cpp, if it exists; if the file does not exist, it will be created when the buffer is saved (e.g. with the Emacs command C-x C-s; see below).
Emacs Commands
Emacs commands are entered using key combinations that include the Control or Escape keys. A quick reference to major commands is provided below. The letter C represents the Control key; the command C-n means "hold the Control key and press n." The letter M stands for "Meta," which is the Escape key on most systems. For example, the command M-a means "press the Escape key, then press the letter a." Do not hold down the Escape key for Meta commands.
File Operations
C-x C-f Retrieve or open a file C-x C-s Save the current file and continue editing C-x C-c Save the current file and exit C-x C-w Write the buffer contents to a file
Cursor Movement
C-n Move to the next line C-p Move to the previous line C-b Move backward one character C-f Move forward one character C-u n C-f Move forward `n' characters (n should be a number) C-a Move to the begining of the line C-e Move to the end of the line M-f Move forward one word M-b Move backward one word M-a Move to the beginning of the sentence M-e Move to the end of the sentence C-v Move forward one screenful M-v Move backward one screenful M-< Move to the begining of the file M-> Move to the end of the file M-g Goto line (prompted for line number)
Editing
C-d Delete one character C-k Kill (cut) from the cursor position to end of line M-k Kill (cut) to the end of the current sentence M-d Kill (cut) the next word after the cursor C-y Yank (paste) the last killed text back
Miscellaneous
C-g Cancel current command C-l Clear screen and redisplay everything, centering the screen on the current cursor position C-x u Undoes one command's worth of changes