{"id":2059,"date":"2013-08-13T07:49:00","date_gmt":"2013-08-13T11:49:00","guid":{"rendered":"http:\/\/irreal.org\/blog\/?p=2059"},"modified":"2013-08-13T12:37:51","modified_gmt":"2013-08-13T16:37:51","slug":"a-vimgolf-in-emacs-challenge","status":"publish","type":"post","link":"https:\/\/irreal.org\/blog\/?p=2059","title":{"rendered":"A VimGolf in Emacs Challenge"},"content":{"rendered":"<p> I&#8217;ve been obsessing and writing about the continuing NSA scandal and as a result we haven&#8217;t had any fun with VimGolf for a while. Just in case you&#8217;re as rusty as I am, here&#8217;s an easy one. <\/p>\n<p> Starting with <\/p>\n<pre class=\"example\">\none two\nthree\n<\/pre>\n<p> transform it to <\/p>\n<pre class=\"example\">\n(one) (two)\n(three)\n<\/pre>\n<p> in the minimum number of keystrokes. <\/p>\n<p> It&#8217;s easy to do this with a straightforward <code>query-replace-regexp<\/code> in 14 keystrokes, which is about the average for the VimGolfers. A slightly more clever use of <code>query-replace-regexp<\/code> gets the job done in 10, which is better than all but one of the VimGolf solutions. <\/p>\n<p> Those are fairly pedestrian solutions but we can do better by leveraging some Emacs power. Using a macro in conjunction with <code>paredit<\/code> does it in 6. Unfortunately, the best VimGolf solution takes only 5. So it&#8217;s up to our Irreal experts to save the honor of Emacsers everywhere. Add your solutions to the comments and I will post mine in a few days. <\/p>\n<p> <b>Update<\/b>: I forgot the give a link to the original VimGolf problem. <a href=\"http:\/\/vimgolf.com\/challenges\/5192f96ad8df110002000002\">Here it is<\/a>. Also, I notice that the solution that solved it in 5 (7 according to VimGolf rules) has been removed. I don&#8217;t know what that means. <\/p>\n<p> Vimgolf \u2192 VimGolf <\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been obsessing and writing about the continuing NSA scandal and as a result we haven&#8217;t had any fun with VimGolf for a while. Just in case you&#8217;re as rusty as I am, here&#8217;s an easy one. Starting with one &hellip; <a href=\"https:\/\/irreal.org\/blog\/?p=2059\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[18],"class_list":["post-2059","post","type-post","status-publish","format-standard","hentry","category-general","tag-emacs"],"_links":{"self":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2059","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=2059"}],"version-history":[{"count":2,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2059\/revisions"}],"predecessor-version":[{"id":2062,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2059\/revisions\/2062"}],"wp:attachment":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2059"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2059"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2059"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}