<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: dev-di</title>
    <description>The latest articles on DEV Community by dev-di (@devdi).</description>
    <link>https://dev.to/devdi</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F538426%2F6c259e8a-fd58-4e7c-90fd-b0ac94abd3dd.png</url>
      <title>DEV Community: dev-di</title>
      <link>https://dev.to/devdi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/devdi"/>
    <language>en</language>
    <item>
      <title>Getting Started with Vim Text Editor</title>
      <dc:creator>dev-di</dc:creator>
      <pubDate>Sun, 22 Aug 2021 15:35:08 +0000</pubDate>
      <link>https://dev.to/devdi/getting-started-with-vim-text-editor-57d1</link>
      <guid>https://dev.to/devdi/getting-started-with-vim-text-editor-57d1</guid>
      <description>&lt;p&gt;Vim is a lightweight and powerful text editor popular on Linux systems. I use Vim mainly for fast editing of small files, such as a configuration file or a script file but it can of course be used for any text editing. This is a beginners guide just scratching the surface of Vim.&lt;/p&gt;

&lt;h1&gt;
  
  
  Start Vim
&lt;/h1&gt;

&lt;p&gt;Start Vim and create the file newfile.txt, or edit it if it already exists.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ vim newfile.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Tips: vim &lt;code&gt;newfile.txt +3&lt;/code&gt; will open the file and put the cursor to line 3 directly.&lt;/p&gt;

&lt;h1&gt;
  
  
  The insert mode and normal mode
&lt;/h1&gt;

&lt;p&gt;One thing making Vim a bit different from many other editors is the modes. I will only mention &lt;em&gt;normal mode&lt;/em&gt; and &lt;em&gt;insert mode&lt;/em&gt; in this article but there are more modes. &lt;/p&gt;

&lt;p&gt;When you start Vim you will enter &lt;em&gt;normal mode&lt;/em&gt; automatically.&lt;/p&gt;

&lt;p&gt;To enter text you need to be in &lt;em&gt;insert mode&lt;/em&gt;. Simply press the &lt;code&gt;i&lt;/code&gt; key or &lt;code&gt;insert&lt;/code&gt; button to enter &lt;em&gt;insert mode&lt;/em&gt;. Now enter some lines in the editor. &lt;/p&gt;

&lt;p&gt;Tips: Did you forget if you are in &lt;em&gt;normal mode&lt;/em&gt; or &lt;em&gt;insert mode&lt;/em&gt;? Check for the  &lt;code&gt;==INSERT==&lt;/code&gt; message at the left bottom of your window. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff2mi02xpnwfzgn9s85jl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff2mi02xpnwfzgn9s85jl.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To enter the normal mode again, press the &lt;code&gt;esc&lt;/code&gt; key.&lt;/p&gt;

&lt;h1&gt;
  
  
  Navigate the text in normal mode
&lt;/h1&gt;

&lt;p&gt;You navigate your cursor with your arrow keys or alternatively with the &lt;code&gt;h&lt;/code&gt; , &lt;code&gt;j&lt;/code&gt;, &lt;code&gt;k&lt;/code&gt; and &lt;code&gt;l&lt;/code&gt; keys:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;h&lt;/code&gt; - move left&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;j&lt;/code&gt; - move down&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;k&lt;/code&gt; - move up&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;l&lt;/code&gt; - move right&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It is totally fine to use the arrow keys, but the &lt;code&gt;hjkl&lt;/code&gt; alternative is recommended for fast navigation since normally the arrow keys are located far away from the alphabetical keys and thus require more time to reach. However, using the &lt;code&gt;hjkl&lt;/code&gt; instead of arrows requires some time to get used to. Give it a try!&lt;/p&gt;

&lt;p&gt;Some more navigation options:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;G&lt;/code&gt; - Go to the last line of the document&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;gg&lt;/code&gt; - Go to the beginning of the document&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;3G&lt;/code&gt; - Go to line 3&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;20l&lt;/code&gt; - Go to column 20 use &lt;code&gt;20l&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note: &lt;code&gt;20l&lt;/code&gt; simply means repeat the l-command 20 times. &lt;/p&gt;

&lt;h1&gt;
  
  
  Search for a Word
&lt;/h1&gt;

&lt;p&gt;To search for the word "Friend" from the &lt;em&gt;normal mode&lt;/em&gt;, enter &lt;code&gt;/Friend&lt;/code&gt; and press enter. It the word Friend is present in the document, the cursor will go to its first location. If you are familiar with the &lt;code&gt;less&lt;/code&gt; program, you will be able to searach a document in Vim in a similar manner.&lt;/p&gt;

&lt;p&gt;Note: The search is case sensitive by default.&lt;/p&gt;

&lt;h1&gt;
  
  
  Save and Exit Vim
&lt;/h1&gt;

&lt;p&gt;To save the current file and exit you enter &lt;code&gt;:wq&lt;/code&gt; from &lt;em&gt;normal mode&lt;/em&gt;. (If you are not in &lt;em&gt;normal mode&lt;/em&gt; enter &lt;code&gt;esc&lt;/code&gt; and then &lt;code&gt;:wq&lt;/code&gt;).&lt;/p&gt;

&lt;h1&gt;
  
  
  More Learning Resources
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;In the terminal enter &lt;code&gt;vimtutor&lt;/code&gt; for a beginner friendly introduction to Vim, including much more than this article.
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftd467k4cnggbfbnyfe5y.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://vim-adventures.com" rel="noopener noreferrer"&gt;Vim adventure&lt;/a&gt; is a fun game for learning Vim commands. The first level is free, give it a try! If you buy the full game you will become an expert Vim user.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4mm0tkke7dxmda01y8zl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4mm0tkke7dxmda01y8zl.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>vim</category>
      <category>texteditor</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
