July 17, 2015
As is widely known, OS X has a collection of keyboard shortcuts involving the arrow keys for editing most text fields including web forms, input boxes, plain text documents, and so on. For example, ββ moves the cursor to the beginning of the current line.
Although they are hidden in plain sight, it seems less widely known that OS X also natively supports certain Emacs keyboard shortcuts in those same text areas. For example, to move to the beginning or end of the current line you can press βA or βE. To delete everything on the current line after the cursor use βK. To transpose the characters on the left and right of the cursor, press βT. To recenter the viewport on the current line, press βL. Shortcβ¦
July 17, 2015
As is widely known, OS X has a collection of keyboard shortcuts involving the arrow keys for editing most text fields including web forms, input boxes, plain text documents, and so on. For example, ββ moves the cursor to the beginning of the current line.
Although they are hidden in plain sight, it seems less widely known that OS X also natively supports certain Emacs keyboard shortcuts in those same text areas. For example, to move to the beginning or end of the current line you can press βA or βE. To delete everything on the current line after the cursor use βK. To transpose the characters on the left and right of the cursor, press βT. To recenter the viewport on the current line, press βL. Shortcuts like these can be faster than using ones involving the arrow keys, which requires moving ones fingers away from the home row of the keyboard.
The table below compares the Emacs keybindings with the OS X ones (the Emacs-like ones and more standard ones). For OS X shortcuts we use the usual symbols for the Command β, Shift β§, Option β₯, Control β, Caps Lock βͺ, Delete β«, and Function Fn keys and write all letter keys in uppercase. Emacs keybindings are expressed in the usual notation for Control C, Meta (Alt) M, Shift S prefixes and the Delete DEL key and we write the letter keys in lowercase.
Emacs and OS X Keyboard Shortcuts Compared Entity Direction Emacs OS X Moving the cursor: move the cursor by character, word, line, etc. char left C-b βB β right C-f βF β word left M-b ββ₯B β₯β right M-f ββ₯F β₯β line begin C-a βA ββ end C-e βE ββ up C-p βP β down C-n βN β doc begin M-< ββ end M-> ββ Selecting text: extend the selection1 by character, word, paragraph, and line char left C-b ββ§B β§β right C-f ββ§F β§β word left M-b ββ₯β§B β₯β§β right M-f ββ₯β§F β₯β§β line begin C-a ββ§A β§ββ end C-e ββ§E β§ββ up C-p ββ§P β§β down C-n ββ§N β§β Deleting text: remove characters, words, and lines char left C-h, DEL βH β« right C-d βD word left M-DEL β₯β« right M-d Fn+β₯β« line backwards Cβ0 C-k ββ« forwards C-k βK Search: find text and move between search results result first C-s βF next C-s βG previous C-r β§βG Scrolling: move and recenter the viewport page up M-v Fn+β down C-v βV Fn+β recenter C-l βL Miscellaneous: other insertion, editing, and kill ring2 commands char transpose C-t βT line insert C-o βO kill C-w βK yank C-y βY
See Also:
- Text System Defaults and Key Bindings from the Cocoa Event Handling Guide in the Mac Developer Library.
- Additional Emacs keyboard shortcuts via a
DefaultKeyBinding.dictfile on GitHub that can be placed in~/Library/KeyBindings.
To enter transient-mark-mode in Emacs, press C-SPC first. β©
1.
The kill ring is an Emacs concept, much like the OS X pasteboard (clipboard), but with a history that can be cycled. The OS X kill and yank commands here make use of a kill ring which is separate from the pasteboard and which can contain only a single element (i.e., no history). β©