{"id":171,"date":"2011-02-17T11:26:51","date_gmt":"2011-02-17T11:26:51","guid":{"rendered":"http:\/\/www.nathanko_website.com\/blog\/?p=171"},"modified":"2016-11-13T17:12:34","modified_gmt":"2016-11-13T17:12:34","slug":"configuring-gvim","status":"publish","type":"post","link":"https:\/\/www.nathankowald.com\/blog\/2011\/02\/configuring-gvim\/","title":{"rendered":"Configuring gVim"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-180 alignright\" style=\"margin-left: 17px; margin-bottom: 17px;\" title=\"vim-editor_logo\" src=\"http:\/\/www.nathankowald.com\/blog\/wp-content\/uploads\/2011\/02\/vim-editor_logo-300x300.png\" alt=\"\" width=\"210\" height=\"210\" srcset=\"https:\/\/www.nathankowald.com\/blog\/wp-content\/uploads\/2011\/02\/vim-editor_logo-300x300.png 300w, https:\/\/www.nathankowald.com\/blog\/wp-content\/uploads\/2011\/02\/vim-editor_logo-150x150.png 150w, https:\/\/www.nathankowald.com\/blog\/wp-content\/uploads\/2011\/02\/vim-editor_logo.png 400w\" sizes=\"auto, (max-width: 210px) 100vw, 210px\" \/><\/p>\n<p>A friend introduced me to the excellent <a href=\"http:\/\/en.wikipedia.org\/wiki\/Vim_(text_editor)\">Vi editor<\/a>.\u00a0His constant talking about how great it is made me curious.\u00a0I purchased\u00a0<a href=\"http:\/\/www.bookdepository.co.uk\/book\/9780596529833\/Learning-the-vi-and-Vim-Editors?a_aid=lowest-price\">Learning the Vi and Vim Editors &#8211; O&#8217;Reilly<\/a> and learnt the basic commands.<\/p>\n<p>My boss prefers Windows: so all our servers are Windows.<br \/>\nI wanted to continue using Vim so started using\u00a0<a href=\"http:\/\/www.vim.org\/download.php#pc\">gVim<\/a>.\u00a0gVim\u00a0is a modified version of the UNIX\u00a0Vi editor.<\/p>\n<p><strong>Here are some things I&#8217;ve needed to configure while using gVim.<\/strong><\/p>\n<h2>Maximising gVim Windows on file open<\/h2>\n<p>The default window size when opening a file in gVim is small.<br \/>\nTo make gVim maximise windows on file open add the following to you <strong>_vimrc<\/strong> \u00a0file.<\/p>\n<pre class=\"prettyprint lang-sh\">\r\n&quot;start maximised\r\nau GUIEnter * simalt ~x<\/pre>\n<p>Your <strong>_vimrc<\/strong> will be in the root folder of your Vim install, mine&#8217;s located in:\u00a0<strong>C:\\Program Files\\Vim\\<\/strong><\/p>\n<p>The <strong>_vimrc<\/strong> file contains optional runtime configuration settings to initialize Vim when it starts.<br \/>\nOn Unix based systems, the file is named\u00a0<strong>.vimrc<\/strong>, on Windows systems it&#8217;s <strong>_vimrc<\/strong>.<\/p>\n<h2>Removing ^M characters in gVim<\/h2>\n<p><strong>^M<\/strong> characters are DOS\/Windows line-ending characters.<br \/>\nPrevious developers at my work used Notepad++ to edit files. When I&#8217;d open these files in gVim they were littered with <strong>^M<\/strong> characters and appear without line breaks or indents. Hard to read and edit.<\/p>\n<p><strong>To remove these use the ex command<\/strong><\/p>\n<pre class=\"prettyprint lang-sh\">:%s\/^M\/\\r\/g<\/pre>\n<p>I encountered a problem typing control characters in Windows.<br \/>\nIn a UNIX environment you type a control character using <kbd>Ctrl<\/kbd>&#8211;<kbd>V<\/kbd>. In Windows <kbd>Ctrl<\/kbd>&#8211;<kbd>V<\/kbd> is used to &#8216;Paste&#8217; so you must use <kbd>Ctrl<\/kbd>&#8211;<kbd>Q<\/kbd> instead.<br \/>\nTo type <strong>^M<\/strong> in gVim you type (<kbd>Ctrl<\/kbd>&#8211;<kbd>Q<\/kbd>) &lt;&#8211; keep your finger on <kbd>Ctrl<\/kbd> then press <kbd>M<\/kbd>.<\/p>\n<pre class=\"prettyprint lang-sh\">\r\n:help CTRL-V-alternative\r\n\r\n*CTRL-V-alternative* *CTRL-Q*\r\nSince CTRL-V is used to paste, you can't use it to start a blockwise Visual\r\nselection.  You can use CTRL-Q instead.  You can also use CTRL-Q in Insert\r\nmode and Command-line mode to get the old meaning of CTRL-V.  But CTRL-Q\r\ndoesn't work for terminals when it's used for control flow.<\/pre>\n<p>Good explanation of <strong>^M<\/strong> characters <a href=\"http:\/\/stackoverflow.com\/questions\/64749\/m-character-at-end-of-lines\/64798#64798\">copied from here<\/a><\/p>\n<blockquote><p>There is a difference between how a Windows-based based OS and a Unix based OS store end-of-line markers.<br \/>\nWindows based operating systems &#8211; thanks to their DOS heritage &#8211; store an end-of-line as a pair of characters &#8211; 0x0A0D. Unix based operating systems just use 0x0A. ^M is a visual representation of 0x0D.<\/p><\/blockquote>\n<h2>Changing the location of gVim swap and backup files<\/h2>\n<p>When editing a file in gVim a backup file is created after saving changes to a newly opened file.<br \/>\nIt is a copy of the file before changing the file. \u00a0It is named the same as the file with a <strong>~<\/strong> at the end.<br \/>\nThis creates a lot of clutter in your directories.<br \/>\nThankfully you can change the default behaviour by disabling swap and backup files or moving the location of these.<\/p>\n<p><strong>To disable swap and backup files add this to your _vimrc file<\/strong><\/p>\n<pre class=\"prettyprint lang-sh\">\r\nset nobackup\r\nset nowritebackup\r\nset noswapfile<\/pre>\n<p>I like to keep these files as it saves the line location that I was last editing.<\/p>\n<p><strong>To change the swap and backup file location add this to your _vimrc file<\/strong><\/p>\n<pre class=\"prettyprint lang-sh\">\r\n&quot;set where to store backups\r\nset backupdir=C:\\vimbackups\r\n\r\n&quot;set where to store swap files\r\nset dir=C:\\vimbackups<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>A friend introduced me to the excellent Vi editor.\u00a0His constant talking about how great it is made me curious.\u00a0I purchased\u00a0Learning the Vi and Vim Editors &#8211; O&#8217;Reilly and learnt the basic commands. My boss prefers Windows: so all our servers are Windows. I wanted to continue using Vim so started using\u00a0gVim.\u00a0gVim\u00a0is a modified version of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[9,7],"tags":[],"class_list":["post-171","post","type-post","status-publish","format-standard","hentry","category-vim","category-web-development"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.nathankowald.com\/blog\/wp-json\/wp\/v2\/posts\/171","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nathankowald.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nathankowald.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nathankowald.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nathankowald.com\/blog\/wp-json\/wp\/v2\/comments?post=171"}],"version-history":[{"count":35,"href":"https:\/\/www.nathankowald.com\/blog\/wp-json\/wp\/v2\/posts\/171\/revisions"}],"predecessor-version":[{"id":1775,"href":"https:\/\/www.nathankowald.com\/blog\/wp-json\/wp\/v2\/posts\/171\/revisions\/1775"}],"wp:attachment":[{"href":"https:\/\/www.nathankowald.com\/blog\/wp-json\/wp\/v2\/media?parent=171"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nathankowald.com\/blog\/wp-json\/wp\/v2\/categories?post=171"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nathankowald.com\/blog\/wp-json\/wp\/v2\/tags?post=171"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}