Emacs Keyboard Shortcut Keys: Complete List (With Functions Explained)

GNU Emacs is the legendary extensible editor, and its entire interface is keyboard commands. The notation is simple once you know it: C-x means hold Ctrl and press x, and M-x means hold Alt (Meta) and press x. This complete list of Emacs keyboard shortcut keys explains files, movement, editing, search, macros and windows in plain words.

Files, Buffers and Help Shortcuts

Shortcut KeyFunction
Ctrl + x, then Ctrl + f (C-x C-f)Find (open) a file
C-x C-sSave the current buffer to its file
C-x sSave some buffers (asks for each modified one)
C-x C-wWrite the buffer to a new file name (Save As)
C-x bSwitch to another buffer by name
C-x C-bList all buffers
C-x Left / Right ArrowPrevious / next buffer
C-x kKill (close) a buffer
C-x C-cExit Emacs
C-gCancel the current command (the universal escape hatch)
C-/ or C-x uUndo
M-xRun any command by name (the Command Palette of Emacs)
C-h tOpen the built-in tutorial
C-h kDescribe what a key does
C-h fDescribe a function
C-h aApropos: search commands by keyword
C-h mDescribe the current major/minor modes and their keys

Movement Shortcuts

Shortcut KeyFunction
C-f / C-bMove forward / backward one character
C-n / C-pMove to the next / previous line
M-f / M-bMove forward / backward one word
C-a / C-eMove to the start / end of the line
M-a / M-eMove to the start / end of the sentence
M-{ / M-}Move to the previous / next paragraph
C-v / M-vScroll down / up one screen
M-< / M->Go to the beginning / end of the buffer
M-g, then g (M-g g)Go to a line number
C-lRecenter the screen on the cursor line (press again for top/bottom)
C-M-f / C-M-bMove forward / backward over a balanced expression (code)
C-M-a / C-M-eGo to the start / end of the current function
C-u {number}Repeat prefix: repeat the next command that many times (e.g. C-u 8 C-n)

Editing Shortcuts

Shortcut KeyFunction
C-dDelete the character after the cursor
Backspace (DEL)Delete the character before the cursor
M-dKill (cut) the word after the cursor
M-BackspaceKill the word before the cursor
C-kKill from the cursor to the end of the line
C-wKill the region (cut the selection)
M-wCopy the region
C-yYank (paste) the last killed text
M-y (after C-y)Cycle through the kill ring history
C-Space (or C-@)Set the mark (start selecting / set a return point)
C-x C-xExchange the cursor and the mark
C-tTranspose two characters
M-tTranspose two words
C-x C-tTranspose two lines
M-u / M-l / M-cUppercase / lowercase / Capitalize the word
C-oOpen a blank line after the cursor
M-^Join this line to the previous line
M-/Complete the word dynamically (from words in open buffers)
M-qFill (re-wrap) the paragraph
C-M-\Indent the region
M-$Run spell checking on the word (ispell)

Search, Replace and Macros Shortcuts

Shortcut KeyFunction
C-sIncremental search forward (repeat C-s for the next match)
C-rIncremental search backward
C-M-s / C-M-rIncremental regular-expression search forward / backward
M-%Query Replace (confirm each replacement with y/n)
C-M-%Query Replace using a regular expression
C-x (Start recording a keyboard macro
C-x )Stop recording the macro
C-x eExecute the last recorded macro (repeat e to run again)
C-x 2Split the window horizontally (one below the other)
C-x 3Split the window vertically (side by side)
C-x oMove to the other window
C-x 0Delete the current window
C-x 1Delete all other windows (keep only this one)
C-x 4 bShow a buffer in another window
C-x 5 2Create a new frame (window in the OS sense)
C-x 5 0Delete the current frame
C-x 5 fOpen a file in a new frame

Tips for Emacs Learners

Three ideas unlock Emacs. First, C-g cancels anything — a stuck command, a long search, a half-typed shortcut. Second, everything has a name: if you know a command's name, M-x runs it, and C-h a finds commands by keyword. Third, the kill ring is smarter than a clipboard: every cut is kept, C-y pastes the newest, and M-y cycles back through everything you cut before.

Frequently Asked Questions

How do I open and save a file in Emacs?

C-x C-f opens a file (type the path and Enter). C-x C-s saves the current buffer; C-x C-w writes it to a new name.

How do I exit Emacs?

C-x C-c. If buffers have unsaved changes, Emacs asks about each one before closing.

What does C-g do in Emacs?

C-g is the universal cancel: it aborts the current command, stops an incremental search and clears a stuck prefix — press it whenever Emacs seems to be waiting for something.

How do I select text in Emacs?

Press C-Space to set the mark, then move the cursor — the text between the mark and the cursor is the selected region, ready for C-w (cut) or M-w (copy).

By Umar Farooq, Tech Know.

Post a Comment

0 Comments