{"id":266,"date":"2011-09-22T16:36:26","date_gmt":"2011-09-22T20:36:26","guid":{"rendered":"http:\/\/irreal.org\/blog\/?p=266"},"modified":"2011-12-26T18:00:57","modified_gmt":"2011-12-26T23:00:57","slug":"setting-the-goal-column-in-emacs","status":"publish","type":"post","link":"https:\/\/irreal.org\/blog\/?p=266","title":{"rendered":"Setting The Goal Column In Emacs"},"content":{"rendered":"\n<p>As you move vertically from line-to-line, Emacs tries to keep the point in the same column position or as near to it as it can. Normally, that&#8217;s what you want to have happen but sometimes it&#8217;s convenient to have the point move to some other column on the next or previous line. You can do that with the <code>set-goal-column<\/code> command, which is bound to \u3010<span class=\"key\">Ctrl<\/span>+<span class=\"key\">x<\/span> <span class=\"key\">Ctrl<\/span>+<span class=\"key\">n<\/span>\u3011. <\/p>\n<p> For example, suppose you have some columnar data such as <\/p>\n<pre class=\"example\">aaa bbb ccc\r\nddd eee fff\r\nggg hhh iii\r\n...\r\n<\/pre>\n<p> and you want to change the second column <\/p>\n<pre class=\"example\">aaa 111 ccc\r\nddd 222 fff\r\nggg 333 iii\r\n...\r\n<\/pre>\n<p> The most direct way of doing that is to put the point on the first <code>b<\/code>, delete the <code>bbb<\/code> with \u3010<span class=\"key\">Meta<\/span>+<span class=\"key\">d<\/span>\u3011, type the <code>111<\/code>, and then move down to the next line. The problem is that the point will then be right after the last <code>e<\/code> so you have to move it to the first <code>e<\/code>, perhaps with a \u3010<span class=\"key\">Meta<\/span>+<span class=\"key\">b<\/span>\u3011. An easier way is to put the point at the first <code>b<\/code> and then set the goal column with \u3010<span class=\"key\">Ctrl<\/span>+<span class=\"key\">x<\/span> <span class=\"key\">Ctrl<\/span>+<span class=\"key\">n<\/span>\u3011.  Then you can delete the <code>bbb<\/code>, type the <code>111<\/code>, and move down to the next line. Now the point will be at the first <code>e<\/code> so you can just delete and type in the <code>222<\/code>. When you&#8217;re finished, you can cancel the goal column with \u3010<span class=\"key\">Ctrl<\/span>+<span class=\"key\">u<\/span> <span class=\"key\">Ctrl<\/span>+<span class=\"key\">x<\/span> <span class=\"key\">Ctrl<\/span>+<span class=\"key\">n<\/span>\u3011. <\/p>\n<p> The <code>set-goal-column<\/code> command is disabled by default so you will need to enable it before its first use. You can let Emacs ask you and then set it permanently or temporarily or you can enable it in your <code>.emacs<\/code> or <code>init.el<\/code> file with <\/p>\n<pre class=\"src src-emacs-lisp\">(put 'set-goal-column 'disabled nil)\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>As you move vertically from line-to-line, Emacs tries to keep the point in the same column position or as near to it as it can. Normally, that&#8217;s what you want to have happen but sometimes it&#8217;s convenient to have the &hellip; <a href=\"https:\/\/irreal.org\/blog\/?p=266\">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-266","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\/266","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=266"}],"version-history":[{"count":1,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/266\/revisions"}],"predecessor-version":[{"id":473,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/266\/revisions\/473"}],"wp:attachment":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=266"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=266"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=266"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}