{"id":388,"date":"2021-09-19T09:07:35","date_gmt":"2021-09-19T17:07:35","guid":{"rendered":"http:\/\/spacefold.com\/colin\/morethanfour\/?p=388"},"modified":"2021-09-19T12:40:42","modified_gmt":"2021-09-19T20:40:42","slug":"learning-git-appendix-b-customizing-the-message-editor","status":"publish","type":"post","link":"https:\/\/spacefold.com\/colin\/morethanfour\/2021\/09\/19\/learning-git-appendix-b-customizing-the-message-editor\/","title":{"rendered":"Learning Git &#8211; Appendix B: Customizing the message editor"},"content":{"rendered":"\n<p>I started out thinking it would be smart to use a GUI editor for Git commits, but after admiring Andreas Kling&#8217;s workflow (<a href=\"https:\/\/www.youtube.com\/c\/AndreasKling\">YouTube<\/a>) I realized that it would be much more efficient to embrace lighter &#8220;terminal&#8221; editors, such as nano or vi.<\/p>\n\n\n\n<p>On Linux Mint, the default Git editor appears to be <strong>nano<\/strong>.<\/p>\n\n\n\n<p>On Windows, using Git Bash, the default Git editor appears to be <strong>vi<\/strong>., and seems to understand Git comment syntax highlighting &#8220;out of the box&#8221;.<\/p>\n\n\n\n<p>I did experiment with using nano, and adding git comment syntax highlighting using the <a rel=\"noreferrer noopener\" href=\"https:\/\/gist.github.com\/keithamus\/736220\/5e069767b22841610ee18fd2f92bd6026f5eb41d\" target=\"_blank\">recommendation here<\/a>. But eventually I decided that learning the few key commands of vi was the best way to go.<\/p>\n\n\n\n<p>So on Linux, I switched:<\/p>\n\n\n\n<pre>$ git config --global core.editor \"vi\"\n$ git commit<\/pre>\n\n\n\n<p>The terminal window now shows the VI editor.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Important Key Commands<\/h4>\n\n\n\n<pre>$ git commit<\/pre>\n\n\n\n<p>The editor opens. Hit <strong>A <\/strong>(to &#8220;Append&#8221;) or <strong>I<\/strong> (to &#8220;Insert&#8221;) before you start typing your commit message.<\/p>\n\n\n\n<p>When you&#8217;re done, hit <strong>[ESCAPE] : W Q <\/strong>to &#8220;Write&#8221; and &#8220;Quit&#8221; and return to the command line. <strong>Don&#8217;t forget the colon!<\/strong><\/p>\n\n\n\n<p>Alternatively, you get configure Git so that vi goes into Insert mode automatically:<\/p>\n\n\n\n<pre>$ git config --global core.editor \"vi -c 'startinsert'\"<\/pre>\n\n\n\n<p>(Thanks to <a href=\"https:\/\/stackoverflow.com\/questions\/11464088\/how-do-i-start-vim-in-insert-mode\">perreal@stackoverflow<\/a>)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I started out thinking it would be smart to use a GUI editor for Git commits, but after admiring Andreas Kling&#8217;s workflow (YouTube) I realized that it would be much more efficient to embrace lighter &#8220;terminal&#8221; editors, such as nano or vi. On Linux Mint, the default Git editor appears to be nano. On Windows, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"class_list":["post-388","post","type-post","status-publish","format-standard","hentry","category-source-control","post-preview"],"_links":{"self":[{"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/posts\/388","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/comments?post=388"}],"version-history":[{"count":0,"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/posts\/388\/revisions"}],"wp:attachment":[{"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/media?parent=388"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/categories?post=388"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/tags?post=388"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}