{"id":11357,"date":"2023-05-14T11:36:43","date_gmt":"2023-05-14T15:36:43","guid":{"rendered":"https:\/\/irreal.org\/blog\/?p=11357"},"modified":"2023-05-14T11:42:00","modified_gmt":"2023-05-14T15:42:00","slug":"adding-c-del-to-the-macos-keybindings","status":"publish","type":"post","link":"https:\/\/irreal.org\/blog\/?p=11357","title":{"rendered":"Adding C-DEL To The macOS Keybindings"},"content":{"rendered":"<p>One of the little known but great features of macOS is their support of Emacs keybindings. Although most people don\u2019t know it, this support comes in two parts. The first is that some of the common Emacs bindings such as <kbd>Ctrl<\/kbd>+<kbd>a<\/kbd>, <kbd>Meta<\/kbd>+<kbd>b<\/kbd>, and similar motion commands are defined by default and work in all macOS apps.<\/p>\n<p>Less well known is that macOS allows you to install your own bindings for all their editing commands. In particular, you can install many of the common Emacs editing commands so that you can leverage your Emacs muscle memory with all the apps on your Mac.<\/p>\n<p>I write about this periodically\u2014last time <a href=\"https:\/\/irreal.org\/blog\/?p=10883\">here<\/a>\u2014when I see an Emacs user discover macOS\u2019s rudimentary support for Emacs motion commands. But this post is not one of my periodic reminders. Rather, it about a missing binding and how easy it is to edit the extended bindings.<\/p>\n<p>For as long as I can remember, I have used both <kbd>Ctrl<\/kbd>+<kbd>Delete<\/kbd> and <kbd>Meta<\/kbd>+<kbd>Delete<\/kbd> to delete the previous word in the manner <a href=\"https:\/\/irreal.org\/blog\/?p=10414\">recommended by Steve Yegge<\/a>. Most of the time, it\u2019s more convenient to use <kbd>Ctrl<\/kbd>+<kbd>Delete<\/kbd> for this but, sadly, that\u2019s not supported by the <code>DefaultKeyBinding.dict<\/code> that I recommended.<\/p>\n<p>Happily, it\u2019s easy to add the desired binding. Here\u2019s the new entry:<\/p>\n<div class=\"org-src-container\">\n<pre class=\"src src-c\"><span style=\"color: #8b2252;\">\"^\\U007F\"<\/span>   = <span style=\"color: #8b2252;\">\"deleteWordBackward:\"<\/span>;            <span style=\"color: #b22222;\">\/* <\/span><span style=\"color: #b22222;\">C-DEL        Delete word backward<\/span><span style=\"color: #b22222;\"> *\/<\/span>\n<\/pre>\n<\/div>\n<p>Just add it to <code>DefaultKeyBinding.dict<\/code> and restart macOS to have it take effect. Pay particular attention to the punctuation after <code>deleteWordBackward<\/code>. It\u2019s fussy and easy to get wrong.<\/p>\n<p>This is a small thing and maybe nobody but me cares but it has made my life a little bit easier. As usual with these things, I wonder why it took me so long.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the little known but great features of macOS is their support of Emacs keybindings. Although most people don\u2019t know it, this support comes in two parts. The first is that some of the common Emacs bindings such as &hellip; <a href=\"https:\/\/irreal.org\/blog\/?p=11357\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[18,194],"class_list":["post-11357","post","type-post","status-publish","format-standard","hentry","category-general","tag-emacs","tag-macos"],"_links":{"self":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/11357","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11357"}],"version-history":[{"count":2,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/11357\/revisions"}],"predecessor-version":[{"id":11359,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/11357\/revisions\/11359"}],"wp:attachment":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11357"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11357"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11357"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}