============================ GNU Emacs keyboard shortcuts ============================ First published at 4/9/2018 on https://defkey.com/gnu-emacs-shortcuts GNU Emacs is the most popular port of the Emacs text editor. It's developed by GNU Project's founder Richard Stallman and dubbed "most powerful text editor of today". GNU Emacs can open text files in multiple character sets and its functionality can be enhanced with Emacs Lisp programs. GNU Emacs has 220 shortcuts and we have listed all of them below. Files ----- Ctrl + X then Ctrl + F Read a file into Emacs Ctrl + X then Ctrl + S Save a file back to disk Ctrl + X then S Save all files Ctrl + X then I Insert contents of another file into this buffer Ctrl + X then Ctrl + V Replace this file with another file Ctrl + X then Ctrl + W Write buffer to specified file Ctrl + X then Ctrl + Q Toggle read only status of buffer Leaving Emacs ------------- Ctrl + Z Suspend or iconify Emacs Ctrl + X then Ctrl + C Exit Emacs completely Help ---- The help system is simple. Type Ctrl + H or F1 and follow the directions. If you are a first time user, type Ctrl + H for a tutorial. Ctrl + X then 1 Remove help window Ctrl + Meta + V Scroll help window Ctrl + H then A Show commands matching a string Ctrl + H then K Describe the function a key runs Ctrl + H then F Describe a function Ctrl + H then M Get mode specific information Error recovery -------------- Ctrl + G Abort partially typed or executing command Meta + X then type recover-session to recover files lost by a system crash Ctrl + X then U Undo an unwanted change Ctrl + _ Undo an unwanted change Ctrl + / Undo an unwanted change Meta + X then type revert-buffer to restore a buffer to its original contents Ctrl + L Redraw garbaged screen Incremental search ------------------ Ctrl + S Search forward Ctrl + R Search backward Ctrl + Meta + S Regular expression search Ctrl + Meta + R Reverse regular expression search Meta + P Select previous search string Meta + N Select next later search string Enter Exit incremental search Del Undo effect of last character Ctrl + G Abort current search Use Ctrl + S or Ctrl + R again to repeat the search in either direction. If Emacs is still searching, Ctrl + G cancels only the part not matched. Motion ------ Ctrl + B Character - backward Ctrl + F Character - forward Meta + B Word - backward Meta + F Word - forward Ctrl + P Line - backward Ctrl + N Line - forward Ctrl + A Go to line beginning Ctrl + E Go to line ending Meta + A Sentence - backward Meta + E Sentence - forward Meta + { Paragraph - backward Meta + } Paragraph - forward Ctrl + X then [ Page - backward Ctrl + X then ] Page - forward Ctrl + Meta + B sexp - backward Ctrl + Meta + F sexp - forward Ctrl + Meta + A function - backward Ctrl + Meta + E function - forward Meta + < Go to beginning of buffer Meta + > Go to end of buffer Ctrl + V Scroll to next screen Meta + V Scroll to previous screen Ctrl + X then < Scroll left Ctrl + X then > Scroll right Ctrl + L Scroll current line to center, top, bottom Meta + G then G Go to line Meta + G then C Go to character Meta + M Back to indentation Killing and deleting -------------------- Del Character (delete, not kill) - backward Ctrl + D Character (delete, not kill) - forward Meta + Del Word - backward Meta + D Word - forward Meta + 0 then Ctrl + K Line (to end of) - backward Ctrl + K Line (to end of) - forward Ctrl + X then Del Sentence - backward Meta + K Sentence - forward Meta + - then Ctrl + Meta + K sexp - backward Ctrl + Meta + K sexp - forward Ctrl + W Kill region Meta + W Copy region to kill ring Meta + Z then press char to kill through next occurence of char Ctrl + Y Yank back last thing killed Meta + Y Replace last yank with previous kill Marking ------- Ctrl + @ Set mark here Ctrl + Space Set mark here Ctrl + X then Ctrl + X Exchange point and mark Meta + @ Set mark arg words away Meta + H Mark paragraph Ctrl + X then Ctrl + P Mark page Ctrl + Meta + @ Mark sexp Ctrl + Meta + H Mark function Ctrl + X then H Mark entire buffer Query replace ------------- Meta + % then Meta + X (then query-replace-regexp) Interactively replace a text string using regular expressions Valid responses in query-replace mode are replace, skip, back up and exit. Space Replace this one, go to next Y Replace this one, go to next Del Skip to next without replacing N Skip to next without replacing ! Replace all remaining matches ^ Back up to the previous match Enter Exit query-replace Ctrl + R Enter recursive edit Ctrl + Meta + C Exit recursive edit Multiple windows ---------------- Ctrl + X then 1 Delete all other windows Ctrl + X then 5 then 1 Delete all other windows (for frame) Ctrl + X then 2 Split window, above and below Ctrl + + X then 5 then 2 Split window, above and below (for frame) Ctrl + X then 0 Delete this window Ctrl + X then 5 then 0 Delete this window (for frame) Ctrl + X then 3 Split window, side by side Ctrl + Meta + V Scroll other window Ctrl + X then O Switch cursor to another window Ctrl + X then 5 then O Switch cursor to another window (for frame) Ctrl + X then 4 then B Select buffer in other window Ctrl + X then 5 then B Select buffer in other window (for frame) Ctrl + X then 4 then Ctrl + O Display buffer in other window Ctrl + X then 5 then Ctrl + O Display buffer in other window (for frame) Ctrl + X then 4 then F Find file in other window Ctrl + X then 5 then F Find file in other window (for frame) Ctrl + X then 4 then R Find file read-only in other window Ctrl + X then 5 then R Find file read-only in other window (for frame) Ctrl + X then 4 then D Run Dired in other window Ctrl + X then 5 then D Run Dired in other window (for frame) Ctrl + X then 4 then . Find tag in other window Ctrl + X then 5 then . Find tag in other window (for frame) Ctrl + X then ^ Grow window taller Ctrl + X then { Shrink window smaller Ctrl + X then } Grow window wider Formatting ---------- Tab Indent current line (mode-dependent) Ctrl + Meta + \ Indent region (mode-dependent) Ctrl + Meta + Q Indent sexp (mode-dependent) Ctrl + X then Tab Indent region rigidly arg columns Meta + ; Indent for comment Ctrl + O Insert newline after point Ctrl + Meta + O Move rest of line vertically down Ctrl + X then Ctrl + O Delete blank lines around point Meta + ^ Join line with previous (with arg, next) Meta + \ Delete all white space around point Meta + Space Put exactly one space at point Meta + Q Fill paragraph Ctrl + X then F Set fill column to arg Ctrl + X then . Prefix each line starts with Meta + O Set face Case change ----------- Meta + U Uppercase word Meta + L Lowercase word Meta + C Capitalize word Ctrl + X then Ctrl + U Uppercase region Ctrl + X then Ctrl + L Lowercase region The minibuffer -------------- The following keys are defined in the minibuffer. Tab Complete as much as possible Space Complete up to one word Enter Complete and execute ? Show possible completions Meta + P Fetch previous minibuffer input Meta + N Fetch later minibuffer input or default Meta + R Regexp search backward through history Meta + S Regexp search forward through history Ctrl + G Abort command Ctrl + X then Esc then Esc Edit and repeat the last command that used the minibuffer F10 Activate menu bar items in text terminals Buffers ------- Ctrl + X then B Select another buffer Ctrl + X then Ctrl + B List all buffers Ctrl + X then K Kill a buffer Transposing ----------- Ctrl + T Transpose characters Meta + T Transpose words Ctrl + X then Ctrl + T Transpose lines Ctrl + Meta + T Transpose sexps Spelling check -------------- Meta + $ Check spelling of current word Meta + X (then ispell-region) Check spelling of all words in region Meta + X (then ispell-buffer) Check spelling of entire buffer Meta + X (then flyspell-mode) Toggle on-the-fly spell checking Tags ---- Meta + . Find a tag (a definition) Ctrl + U then Meta + . Find next occurence of a tag Meta + X (then visit-tags-table) Specify new tags file Meta + X (then tags-search) Regexp search on all files in tags table Meta + X (then tags-query-replace) Run query-replace on all the files Meta + , Continue last tags search on query-replace Shells ------ Meta + ! Execute a shell command Meta + & Execute a shell command asynchronously Meta + | Run a shell command on the region Meta + X (then type shell) Start a shell window *shell* Rectangles ---------- Ctrl + X then R then R Copy rectangle to register Ctrl + X then R then K Kill rectangle Ctrl + X then R then Y Yank rectangle Ctrl + X then R then O Open rectangle, shifting text right Ctrl + X then R then C Black out rectangle Ctrl + X then R then T Prefix each line with string Abbrevs ------- Ctrl + X then A then G Add global abbrev Ctrl + X then A then L Add mode-local abbrev Ctrl + X then A then I then G Add global expansion for this abbrev Ctrl + X then A then I then L Add mode-local expansion for this abbrev Ctrl + X then A then E Explicitly expand abbrev Meta + / Expand previous word dynamically Miscellaneous ------------- Ctrl + U then [Num 0 - 9] Numeric argument Meta + - Negative argument Ctrl + Q then char: Quoted insert International character sets ---------------------------- Ctrl + \ Enable or disable input method Info ---- Ctrl + H then I Enter the Info documentation reader Ctrl + H then S Find specified function or variable in Info Space Scroll forward Del Scroll reverse B Beginning of node N Go to next node P Go to previous node U Move up M Select menu item by name [Num 1 - 9] Select menu item by number F Follow cross reference (return with 1) L Return to last node you saw D Return to directory node T Go to top node of Info file G Go to any node by name H Run info tutorial I Look up a subject in the indices S Search nodes for regexp Q Quit Info Registers --------- Ctrl + X then R then S Save region in register Ctrl + X then R then I Insert register contents into buffer Ctrl + X then R then Space Save value of point in register Ctrl + X then R then J Jump to point saved in register Keyboard macros --------------- Ctrl + X then ( Start defining a keyboard macro Ctrl + X then ) End keyboard macro definition Ctrl + X then E Eappend to last keyboard macro Meta + X (then name-last-kbd-macro) name last keyboard macro Meta + X (then insert-kbd-macro) Instert Lisp definition in buffer Dealing with Emacs Lisp ----------------------- Ctrl + X then Ctrl + E Eval sexp before point Ctrl + Meta + X Eval current defun Meta + X (then eval-region) Eval region Meta + : Read and eval minibuffer Meta + X (then load-library) load a Lisp library from load-path Simple customization -------------------- Meta + X (then customize) Customize variables and faces Source: GNU Emacs refcard Last modified on (UTC): Monday, November 11, 2019 Defkey © All rights reserved.