{"id":73,"date":"2008-12-29T17:06:38","date_gmt":"2008-12-29T22:06:38","guid":{"rendered":"http:\/\/stoney.sb.org\/wordpress\/?p=73"},"modified":"2009-06-03T18:40:41","modified_gmt":"2009-06-03T23:40:41","slug":"adding-a-keyboard-shortcut-to-mathematica-v7","status":"publish","type":"post","link":"https:\/\/stoney.sb.org\/wordpress\/adding-a-keyboard-shortcut-to-mathematica-v7\/","title":{"rendered":"Adding a keyboard shortcut to Mathematica V7"},"content":{"rendered":"<p>(updated 2009-03-23 to add the backslashes that disappeared between my blog editor and WordPress)<\/p>\n<p>In Mathematica, typing index brackets is clumsy, as one has to type esc-[[-esc then esc-]]-esc. I found a way to modify the Edit menu to add a shortcut for this.<!--more--><br \/>\nI don&#8217;t know how this would be done from non-Macintosh systems, but on Macintosh, you copy the file &#8220;\/Applications\/Mathematica.app\/SystemFiles\/FrontEnd\/TextResources\/Macintosh\/MenuSetup.tr&#8221; (in the Application bundle) into &#8220;~\/Library\/Mathematica\/SystemFiles\/FrontEnd\/TextResources\/Macintosh\/MenuSetup.tr&#8221;. Then, edit it using a plain text editor like BBEdit, or even with Mathematica itself.<\/p>\n<p>In this file, find the line<\/p>\n<pre lang=\"Mathematica\">\r\nMenuItem[\"Matching []\", \"InsertMatchingBrackets\", MenuKey[\"]\", Modifiers->{\"Command\", \"Option\"}]],\r\n<\/pre>\n<p>In the same block of menu items, add this<\/p>\n<pre lang=\"Mathematica\">\r\nMenuItem[\"Matching [LeftDoubleBracket][RightDoubleBracket]\",\r\n    FrontEndExecute[{\r\n        FrontEnd`NotebookApply[FrontEnd`InputNotebook[],\r\n            \"[LeftDoubleBracket][SelectionPlaceholder][RightDoubleBracket]\"]}],\r\n    MenuKey[\"]\", Modifiers->{\"Command\", \"Option\", \"Control\"}]],\r\n<\/pre>\n<p>You have to restart Mathematica for it to see this change, but now you can wrap index brackets around the selection by typing cmd-opt-ctl-].<\/p>\n<p>This is different from the other &#8220;Matching&#8230;&#8221; insertions, as it wraps the brackets around the selection, or leaves a &#8220;placeholder&#8221; selected if there was no selection rather than replacing the selection with the insertion. Since I&#8217;m used to editors that wrap the selection in this case, I&#8217;ve also changed the existing &#8220;Matching&#8230;&#8221; menu items to use this same technique.<\/p>\n<p>This is what I have now:<\/p>\n<pre lang=\"Mathematica\">\r\nMenuItem[\"Matching []\",\r\n    FrontEndExecute[{\r\n        FrontEnd`NotebookApply[\r\n            FrontEnd`InputNotebook[],\"[[SelectionPlaceholder]]\"]}],\r\n    MenuKey[\"]\", Modifiers->{\"Command\", \"Option\"}]],\r\nMenuItem[\"Matching {}\",\r\n    FrontEndExecute[{\r\n        FrontEnd`NotebookApply[\r\n            FrontEnd`InputNotebook[],\"{[SelectionPlaceholder]}\"]}],\r\n    MenuKey[\"}\", Modifiers->{\"Command\", \"Option\"}]],\r\nMenuItem[\"Matching ()\",\r\n    FrontEndExecute[{\r\n        FrontEnd`NotebookApply[\r\n            FrontEnd`InputNotebook[],\"([SelectionPlaceholder])\"]}],\r\n    MenuKey[\")\", Modifiers->{\"Command\", \"Option\"}]],\r\nMenuItem[\"Matching [LeftDoubleBracket][RightDoubleBracket]\",\r\n    FrontEndExecute[{\r\n        FrontEnd`NotebookApply[\r\n            FrontEnd`InputNotebook[],\"[LeftDoubleBracket][SelectionPlaceholder][RightDoubleBracket]\"]}],\r\n    MenuKey[\"]\", Modifiers->{\"Command\", \"Option\", \"Control\"}]],\r\n<\/pre>\n<p>These changes should survive minor updates to Mathematica, but it&#8217;s best to keep a copy of your file in case some later update replaces it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>(updated 2009-03-23 to add the backslashes that disappeared between my blog editor and WordPress) In Mathematica, typing index brackets is clumsy, as one has to type esc-[[-esc then esc-]]-esc. I found a way to modify the Edit menu to add a shortcut for this.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[13,20,14],"tags":[],"jetpack_publicize_connections":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Adding a keyboard shortcut to Mathematica V7 - Stoney&#039;s Zone<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/stoney.sb.org\/wordpress\/adding-a-keyboard-shortcut-to-mathematica-v7\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Adding a keyboard shortcut to Mathematica V7 - Stoney&#039;s Zone\" \/>\n<meta property=\"og:description\" content=\"(updated 2009-03-23 to add the backslashes that disappeared between my blog editor and WordPress) In Mathematica, typing index brackets is clumsy, as one has to type esc-[[-esc then esc-]]-esc. I found a way to modify the Edit menu to add a shortcut for this.\" \/>\n<meta property=\"og:url\" content=\"http:\/\/stoney.sb.org\/wordpress\/adding-a-keyboard-shortcut-to-mathematica-v7\/\" \/>\n<meta property=\"og:site_name\" content=\"Stoney&#039;s Zone\" \/>\n<meta property=\"article:published_time\" content=\"2008-12-29T22:06:38+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2009-06-03T23:40:41+00:00\" \/>\n<meta name=\"author\" content=\"stoney\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"stoney\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"http:\/\/stoney.sb.org\/wordpress\/adding-a-keyboard-shortcut-to-mathematica-v7\/\",\"url\":\"http:\/\/stoney.sb.org\/wordpress\/adding-a-keyboard-shortcut-to-mathematica-v7\/\",\"name\":\"Adding a keyboard shortcut to Mathematica V7 - Stoney's Zone\",\"isPartOf\":{\"@id\":\"https:\/\/stoney.sb.org\/wordpress\/#website\"},\"datePublished\":\"2008-12-29T22:06:38+00:00\",\"dateModified\":\"2009-06-03T23:40:41+00:00\",\"author\":{\"@id\":\"https:\/\/stoney.sb.org\/wordpress\/#\/schema\/person\/d587bd16a4b79558c4f6e01c078fbdb1\"},\"breadcrumb\":{\"@id\":\"http:\/\/stoney.sb.org\/wordpress\/adding-a-keyboard-shortcut-to-mathematica-v7\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/stoney.sb.org\/wordpress\/adding-a-keyboard-shortcut-to-mathematica-v7\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/stoney.sb.org\/wordpress\/adding-a-keyboard-shortcut-to-mathematica-v7\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/stoney.sb.org\/wordpress\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Adding a keyboard shortcut to Mathematica V7\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/stoney.sb.org\/wordpress\/#website\",\"url\":\"https:\/\/stoney.sb.org\/wordpress\/\",\"name\":\"Stoney's Zone\",\"description\":\"Thoughts about stuff\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/stoney.sb.org\/wordpress\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/stoney.sb.org\/wordpress\/#\/schema\/person\/d587bd16a4b79558c4f6e01c078fbdb1\",\"name\":\"stoney\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/stoney.sb.org\/wordpress\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/47ff741e5568d1283ae1d29cfa4248fa?s=96&d=mm&r=pg\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/47ff741e5568d1283ae1d29cfa4248fa?s=96&d=mm&r=pg\",\"caption\":\"stoney\"},\"sameAs\":[\"http:\/\/\"],\"url\":\"https:\/\/stoney.sb.org\/wordpress\/author\/stoney\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Adding a keyboard shortcut to Mathematica V7 - Stoney's Zone","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/stoney.sb.org\/wordpress\/adding-a-keyboard-shortcut-to-mathematica-v7\/","og_locale":"en_US","og_type":"article","og_title":"Adding a keyboard shortcut to Mathematica V7 - Stoney's Zone","og_description":"(updated 2009-03-23 to add the backslashes that disappeared between my blog editor and WordPress) In Mathematica, typing index brackets is clumsy, as one has to type esc-[[-esc then esc-]]-esc. I found a way to modify the Edit menu to add a shortcut for this.","og_url":"http:\/\/stoney.sb.org\/wordpress\/adding-a-keyboard-shortcut-to-mathematica-v7\/","og_site_name":"Stoney's Zone","article_published_time":"2008-12-29T22:06:38+00:00","article_modified_time":"2009-06-03T23:40:41+00:00","author":"stoney","twitter_card":"summary_large_image","twitter_misc":{"Written by":"stoney","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"http:\/\/stoney.sb.org\/wordpress\/adding-a-keyboard-shortcut-to-mathematica-v7\/","url":"http:\/\/stoney.sb.org\/wordpress\/adding-a-keyboard-shortcut-to-mathematica-v7\/","name":"Adding a keyboard shortcut to Mathematica V7 - Stoney's Zone","isPartOf":{"@id":"https:\/\/stoney.sb.org\/wordpress\/#website"},"datePublished":"2008-12-29T22:06:38+00:00","dateModified":"2009-06-03T23:40:41+00:00","author":{"@id":"https:\/\/stoney.sb.org\/wordpress\/#\/schema\/person\/d587bd16a4b79558c4f6e01c078fbdb1"},"breadcrumb":{"@id":"http:\/\/stoney.sb.org\/wordpress\/adding-a-keyboard-shortcut-to-mathematica-v7\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/stoney.sb.org\/wordpress\/adding-a-keyboard-shortcut-to-mathematica-v7\/"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/stoney.sb.org\/wordpress\/adding-a-keyboard-shortcut-to-mathematica-v7\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/stoney.sb.org\/wordpress\/"},{"@type":"ListItem","position":2,"name":"Adding a keyboard shortcut to Mathematica V7"}]},{"@type":"WebSite","@id":"https:\/\/stoney.sb.org\/wordpress\/#website","url":"https:\/\/stoney.sb.org\/wordpress\/","name":"Stoney's Zone","description":"Thoughts about stuff","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/stoney.sb.org\/wordpress\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/stoney.sb.org\/wordpress\/#\/schema\/person\/d587bd16a4b79558c4f6e01c078fbdb1","name":"stoney","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/stoney.sb.org\/wordpress\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/47ff741e5568d1283ae1d29cfa4248fa?s=96&d=mm&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/47ff741e5568d1283ae1d29cfa4248fa?s=96&d=mm&r=pg","caption":"stoney"},"sameAs":["http:\/\/"],"url":"https:\/\/stoney.sb.org\/wordpress\/author\/stoney\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p76dm1-1b","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/stoney.sb.org\/wordpress\/wp-json\/wp\/v2\/posts\/73"}],"collection":[{"href":"https:\/\/stoney.sb.org\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/stoney.sb.org\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/stoney.sb.org\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/stoney.sb.org\/wordpress\/wp-json\/wp\/v2\/comments?post=73"}],"version-history":[{"count":20,"href":"https:\/\/stoney.sb.org\/wordpress\/wp-json\/wp\/v2\/posts\/73\/revisions"}],"predecessor-version":[{"id":106,"href":"https:\/\/stoney.sb.org\/wordpress\/wp-json\/wp\/v2\/posts\/73\/revisions\/106"}],"wp:attachment":[{"href":"https:\/\/stoney.sb.org\/wordpress\/wp-json\/wp\/v2\/media?parent=73"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/stoney.sb.org\/wordpress\/wp-json\/wp\/v2\/categories?post=73"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/stoney.sb.org\/wordpress\/wp-json\/wp\/v2\/tags?post=73"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}