{"id":647,"date":"2023-08-28T17:26:40","date_gmt":"2023-08-28T15:26:40","guid":{"rendered":"https:\/\/www.petersplanet.nl\/?p=647"},"modified":"2023-08-28T17:28:33","modified_gmt":"2023-08-28T15:28:33","slug":"line-breaks-in-visual-studio-code-and-git-lf-vs-crlf","status":"publish","type":"post","link":"https:\/\/www.petersplanet.nl\/index.php\/2023\/08\/28\/line-breaks-in-visual-studio-code-and-git-lf-vs-crlf\/","title":{"rendered":"Line breaks in Visual STudio Code and Git (LF vs CRLF)"},"content":{"rendered":"\n<p><strong>Background<\/strong><br>In Windows a line break ends with the characters &lt;CR>&lt;LF> and in Linux a line break is only a &lt;LF>.<br>So usually line breaks in text files in Windows should be ending with &lt;CR>&lt;LF> and in Linux they should end with &lt;LF>. In mixed environments (Windows\/Linux) this is something one has to take into account.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p><strong>Visual Studio Code<\/strong><br>In VS Code you easily see which line breaks are being used for a file. This can be seen at the right bottom of a file. It can be changed by clicking on it (LF or CRLF).<br><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"60\" class=\"wp-image-648\" style=\"width: 300px;\" src=\"https:\/\/www.petersplanet.nl\/wp-content\/uploads\/2023\/08\/image.png\" alt=\"\" srcset=\"https:\/\/www.petersplanet.nl\/wp-content\/uploads\/2023\/08\/image.png 407w, https:\/\/www.petersplanet.nl\/wp-content\/uploads\/2023\/08\/image-300x60.png 300w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><br>You can also change the default for new files in the settings with the &#8220;files.eol&#8221; property.<\/p>\n\n\n\n<p><strong>Git<\/strong><br>Line breaks are also something in Git. You can influence the behaviour of it with the core.autocrlf property.<br>If you don&#8217;t want Git to change the line break settings you have to set &#8220;core.autocrlf&#8221; to false.<br><code>git config --global core.autocrlf false<\/code><br>See the Git <a href=\"https:\/\/git-scm.com\/book\/en\/v2\/Customizing-Git-Git-Configuration\">documentation<\/a> for other values.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>BackgroundIn Windows a line break ends with the characters &lt;CR>&lt;LF> and in Linux a line break is only a &lt;LF>.So usually line breaks in text files in Windows should be ending with &lt;CR>&lt;LF> and in Linux they should end with &lt;LF>. In mixed environments (Windows\/Linux) this is something one has to take into account.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,9],"tags":[],"class_list":["post-647","post","type-post","status-publish","format-standard","hentry","category-linux","category-programming"],"_links":{"self":[{"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/posts\/647","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/comments?post=647"}],"version-history":[{"count":19,"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/posts\/647\/revisions"}],"predecessor-version":[{"id":667,"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/posts\/647\/revisions\/667"}],"wp:attachment":[{"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/media?parent=647"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/categories?post=647"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/tags?post=647"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}