{"id":21381,"date":"2018-04-29T15:16:25","date_gmt":"2018-04-29T19:16:25","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=21381"},"modified":"2023-02-14T15:17:59","modified_gmt":"2023-02-14T20:17:59","slug":"multiple-cursors-in-xcode","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2018\/04\/29\/multiple-cursors-in-xcode\/","title":{"rendered":"Multiple Cursors in Xcode"},"content":{"rendered":"<p><a href=\"https:\/\/twitter.com\/dmartincy\/status\/988094014804160514\">Daniel Mart&iacute;n<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/dmartincy\/status\/988094014804160514\">\n<p>For the new refactoring engine, the Xcode team developed a simple implementation for testing, but kept it disabled:<\/p>\n<pre>defaults write com.apple.dt.Xcode PegasusMultipleCursorsEnabled -bool true<\/pre>\n<\/blockquote>\n<blockquote cite=\"https:\/\/twitter.com\/dmartincy\/status\/988144359584534529\"><p>Press Command and click\/select some text and the editor will create a new cursor.<\/p><\/blockquote>\n<p>Any edits that you make are then repeated by all the cursors simultaneously. This can make certain batch changes faster and more reliable than doing them one-by-one, and for many common cases it&rsquo;s easier (and requires less of a mental context switch) than writing a regular expression or script. The Xcode implementation is difficult to use in practice, though, because when Command is down, Xcode often wants to do something with the word I&rsquo;m clicking on\/near, rather than letting me place the cursor. Also, the edits are not bundled into undo groups the way you would expect.<\/p>\n\n<p>Update (2018-06-04): <a href=\"https:\/\/twitter.com\/olebegemann\/status\/1003721681301622785\">Ole Begemann<\/a> on Xcode 10:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/olebegemann\/status\/1003721681301622785\">\n<p>&ldquo;The Xcode Source Editor now supports multi-cursor editing allowing you to quickly edit multiple ranges of code at once.<\/p>\n<p>Place additional cursors via &#x2303;+&#x21E7;+Click or with column select (&#x2325;+Click+Drag), or using &#x2303;+&#x21E7;+Up\/Down.&rdquo;<\/p>\n<\/blockquote>\n\n<p>Update (2018-08-02): <a href=\"https:\/\/twitter.com\/bzamayo\/status\/1024983650293698560\">Benjamin Mayo<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/bzamayo\/status\/1024983650293698560\">\n<p>Xcode 10 multiple cursors are too good not to share.<\/p>\n<\/blockquote>\n\n<p id=\"multiple-cursors-in-xcode-update-2020-11-27\">Update (2020-11-27): <a href=\"https:\/\/twitter.com\/davedelong\/status\/1147229851373326336\">Dave DeLong<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/davedelong\/status\/1147229851373326336\">\n<p>Discovered a way in #Xcode to do an &ldquo;edit all&rdquo; that&rsquo;s not limited to declarations<\/p>\n<ol>\n<li>select the thing you want to edit<\/li>\n<li>press-and-hold &#x2325;&#x2318;E to &ldquo;select next occurrence&rdquo; until everything&rsquo;s selected<\/li>\n<li>type in the replacement; all of &lsquo;em get changed<\/li>\n<\/ol>\n<\/blockquote>\n\n<p id=\"multiple-cursors-in-xcode-update-2023-02-14\">Update (2023-02-14): <a href=\"https:\/\/useyourloaf.com\/blog\/xcode-multi-cursor-editing\/\">Keith Harrison<\/a>:<\/p>\n<blockquote cite=\"https:\/\/useyourloaf.com\/blog\/xcode-multi-cursor-editing\/\">\n<p>I found myself rediscovering Xcode&rsquo;s multi-cursor support this week. Here&rsquo;s a reminder in case you need it.<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Daniel Mart&iacute;n: For the new refactoring engine, the Xcode team developed a simple implementation for testing, but kept it disabled: defaults write com.apple.dt.Xcode PegasusMultipleCursorsEnabled -bool true Press Command and click\/select some text and the editor will create a new cursor. Any edits that you make are then repeated by all the cursors simultaneously. This can [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2018-08-02T16:44:17Z","apple_news_api_id":"192e0df1-f26c-421f-a331-54d5ea7d147f","apple_news_api_modified_at":"2023-02-14T20:18:07Z","apple_news_api_revision":"AAAAAAAAAAAAAAAAAAAABA==","apple_news_api_share_url":"https:\/\/apple.news\/AGS4N8fJsQh-jMVTV6n0Ufw","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[2],"tags":[649,30,1529,71,816,68,226],"class_list":["post-21381","post","type-post","status-publish","format-standard","hentry","category-technology","tag-esoteric-preferences","tag-mac","tag-macos-10-13","tag-programming","tag-refactoring","tag-texteditor","tag-xcode"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/21381","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=21381"}],"version-history":[{"count":5,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/21381\/revisions"}],"predecessor-version":[{"id":38454,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/21381\/revisions\/38454"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=21381"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=21381"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=21381"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}