<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Vim on blog.iankulin.com</title><link>https://blog.iankulin.com/tags/vim/</link><description>Recent content in Vim on blog.iankulin.com</description><generator>Hugo</generator><language>en-AU</language><lastBuildDate>Thu, 10 Aug 2023 00:00:00 +0000</lastBuildDate><atom:link href="https://blog.iankulin.com/tags/vim/index.xml" rel="self" type="application/rss+xml"/><item><title>Bloody VIM</title><link>https://blog.iankulin.com/bloody-vim/</link><pubDate>Thu, 10 Aug 2023 00:00:00 +0000</pubDate><guid>https://blog.iankulin.com/bloody-vim/</guid><description>&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Vim is a highly configurable text editor built to make creating and changing any kind of text very efficient. It is included as &amp;ldquo;vi&amp;rdquo; with most UNIX systems and with Apple OS X.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.vim.org/"&gt;vim.org&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;You will encounter vi/vim as the incomprehensible text editor that pops up by default when you need to edit something in your sysadmin journey. Perhaps you issued the command to edit your Ansible vault, perhaps you forgot to add a message to a commit. It&amp;rsquo;s going to be unavoidable.&lt;/p&gt;
&lt;p&gt;Here is the minimum knowledge you need to survive these encounters.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;It has modes. When it opens up, you are in &amp;lsquo;moving around mode&amp;rsquo;. Use the cursor keys to get to where you need to.&lt;/li&gt;
&lt;li&gt;When you actually want to edit something, press &lt;code&gt;i&lt;/code&gt; now you&amp;rsquo;re in &lt;em&gt;INSERT&lt;/em&gt; mode and it&amp;rsquo;s behaving how 99% of the world expect an editor to behave. When you type things, they go into the document where the cursor is.&lt;/li&gt;
&lt;li&gt;When you are done, press &lt;em&gt;escape&lt;/em&gt; to get out of INSERT mode, then these keys one at a time &lt;code&gt;: w q&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The underlying theory of Vim - that you spend more time moving around in text than editing it, is true of most sysadmin and programming tasks. So Vim has powerful, non-intuitive commands to do that efficiently. It&amp;rsquo;s impressive to watch people who have learned these arcane ways move around a file. They don&amp;rsquo;t have girlfriends. There are also powerful, non-intuitive commands for editing.&lt;/p&gt;</description></item><item><title>Vim</title><link>https://blog.iankulin.com/vim/</link><pubDate>Wed, 10 Aug 2022 00:00:00 +0000</pubDate><guid>https://blog.iankulin.com/vim/</guid><description>&lt;img src="https://blog.iankulin.com/images/1-_bwvjb2jzuuzyxgxm6xwqq.png" width="191" alt=""&gt;
&lt;p&gt;I&amp;rsquo;ve been working through the &lt;a href="https://missing.csail.mit.edu/"&gt;Missing Semester&lt;/a&gt; lectures from MIT, and recently completed the lecture about the &lt;a href="https://github.com/vim/vim"&gt;Vim editor&lt;/a&gt;. Vim is a test editor, called from the command line, and optimised for programming - in the sense that it assumes most of the use of the editor is navigating around a big text file making small changes rather than entering large amount of test.&lt;/p&gt;
&lt;p&gt;It uses simple, short key presses (as opposed to mouse movements or using menus or toolbars) to achieve things. This makes it highly efficient for good typists who know all the commands, and slightly incomprehensible to those who do not. An additional level of complexity is the idea of modes. Vim has several modes, the main ones being:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Normal - for navigating around and making those little edits. To get into this mode press the esc key&lt;/li&gt;
&lt;li&gt;Insert - for entering text - ie the mode you&amp;rsquo;d assume you were in when opening an editor and not that you would have to press the letter &amp;lsquo;i&amp;rsquo; to make that happen&lt;/li&gt;
&lt;li&gt;Command - to run commands - like saving or closing VIM To get into this mode press the &amp;lsquo;:&amp;rsquo; key&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Apart from &lt;a href="https://missing.csail.mit.edu/2020/editors/"&gt;this lecture&lt;/a&gt; here are many good guides for learning VIM, a couple I&amp;rsquo;ve looked at are &lt;a href="https://opensource.com/article/19/3/getting-started-vim"&gt;this one from OpenSource.com&lt;/a&gt; and &lt;a href="https://web.stanford.edu/class/cs107/resources/vim.html"&gt;this one from Stanford&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Even though I will never invest the time to become a power user of Vim, it&amp;rsquo;s available most places you&amp;rsquo;ll be using the command line, so the basics are a requirement for any programmer. Plus if you&amp;rsquo;re ever hired by a film production company to advise on a computer hacking scene, you&amp;rsquo;ll need it to scroll though some syntax highlighted Javascript.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.vimcheatsheet.com/"&gt;&lt;img src="https://blog.iankulin.com/images/iigrixvxp5ayn9ox7gr1dfi_rhlrotwllscafjjqjeq.webp" alt=""&gt;&lt;/a&gt;
&lt;em&gt;Great cheat sheet from &lt;a href="https://www.vimcheatsheet.com/"&gt;https://www.vimcheatsheet.com/&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;</description></item><item><title>Gitting Started</title><link>https://blog.iankulin.com/gitting-started/</link><pubDate>Wed, 13 Jul 2022 00:00:00 +0000</pubDate><guid>https://blog.iankulin.com/gitting-started/</guid><description>&lt;p&gt;One of my early goals was to get in the habit of using version control with Git/Github, and I&amp;rsquo;ve got that sorted out today. My source was this excellent, very clear video from &lt;a href="https://www.youtube.com/channel/UCxA99Yr6P_tZF9_BgtMGAWA"&gt;Gwen Faraday&lt;/a&gt;. I highly recommend it if you are just starting.&lt;/p&gt;
&lt;div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;"&gt;
 &lt;iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen" loading="eager" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube.com/embed/RGOj5yH7evk?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" title="YouTube video"&gt;&lt;/iframe&gt;
 &lt;/div&gt;

&lt;p&gt;It possibly helped that I&amp;rsquo;m also on mac, so I didn&amp;rsquo;t have to deal with the &amp;ldquo;or however that&amp;rsquo;s done on your system&amp;rdquo; type problems. Also, where things didn&amp;rsquo;t work as expected, the explanation about what was being done was clear enough that the problem was solvable. For example, the push command Gwen used was:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#d8dee9;background-color:#2e3440;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;git push origin master
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;but GitHub had defaulted my initial branch to &amp;ldquo;main&amp;rdquo; rather than &amp;ldquo;master&amp;rdquo;. Easily fixed since she immediately explained what both of those modifiers were. The only other tiny bit of troubleshooting was that my git global config wasn&amp;rsquo;t set up, so my commit was followed by a big message pointing out that my real email address wasn&amp;rsquo;t used for the commit:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#d8dee9;background-color:#2e3440;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; Committer: User Name &amp;lt;username@Ians-MacBook-Pro.local&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Your name and email address were configured automatically based
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;on your username and hostname. Please check that they are accurate.
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;You can suppress this message by setting them explicitly. Run the
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;following command and follow the instructions in your editor to edit
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;your configuration file:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; git config --global --edit
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;After doing this, you may fix the identity used for this commit with:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; git commit --amend --reset-author
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It didn&amp;rsquo;t make any difference - the file I&amp;rsquo;d created locally pushed up to the GitHub repo just fine. When I did follow those instructions to edit the file, I suddenly needed to know how to use Vim (hint: &amp;ldquo;i&amp;rdquo; to go into insert mode for editing, then &amp;ldquo;:&amp;rdquo; for command mode and &amp;ldquo;x&amp;rdquo; to exit and save).&lt;/p&gt;
&lt;p&gt;The only real complexity in the whole process was generating the SSH key and saving that on GitHub to allow the push from your local directory up to the GitHub repository.&lt;/p&gt;
&lt;p&gt;Ignoring that, the process was:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Creating the repository via on GitHub&lt;/li&gt;
&lt;li&gt;Using &lt;code&gt;git clone&lt;/code&gt; to download the repository to the local machine and set it up for tracking in git&lt;/li&gt;
&lt;li&gt;Edit/create the files, however. Gwen used Visual Studio code, I used my tools&lt;/li&gt;
&lt;li&gt;Check status with &lt;code&gt;git status&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;git add .&lt;/code&gt; to stage the new files and freshly edited files&lt;/li&gt;
&lt;li&gt;Commit those changes with &lt;code&gt;git commit -m &amp;quot;commit title&amp;quot; -m &amp;quot;description&amp;quot;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Then push them up to GitHub with &lt;code&gt;git push origin main&lt;/code&gt; where &amp;ldquo;main&amp;rdquo; is the branch name.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All of that was by about the 25 minute mark in the video, and is probably enough for me to go away and get some practice with. The rest covers getting an already established local git repository to GitHub, branching, forking, undoing.&lt;/p&gt;</description></item></channel></rss>