<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ vim - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ vim - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Fri, 08 May 2026 14:35:20 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/vim/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ How to Use the Vim Text Editor – An Introduction for Developers ]]>
                </title>
                <description>
                    <![CDATA[ Imagine a carpenter without tools, a writer without a pen, or a chef without a knife—this is like trying to imagine a developer or sysadmin without a reliable text editor. For devs, text editors are the ultimate multitools, shaping how we create, man... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-use-the-vim-text-editor-intro-for-devs/</link>
                <guid isPermaLink="false">67a24bb37e501febb084c852</guid>
                
                    <category>
                        <![CDATA[ vim ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Linux ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Text Editors ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Tanishka Makode ]]>
                </dc:creator>
                <pubDate>Tue, 04 Feb 2025 17:17:39 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1738684583892/739ec0fa-e8a2-4f08-a265-7fa5034c932d.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Imagine a carpenter without tools, a writer without a pen, or a chef without a knife—this is like trying to imagine a developer or sysadmin without a reliable text editor.</p>
<p>For devs, text editors are the ultimate multitools, shaping how we create, manage, and transform raw data into meaningful output.</p>
<p>While modern editors like VS Code and Sublime Text have gained popularity for their sleek interfaces, there’s something timeless about the simplicity and power of classic tools.</p>
<p>Loved by some and feared by others, Vim is a text editor that has stood the test of time. Born from its predecessor Vi, Vim (Vi Improved) offers unparalleled speed, versatility, and control.</p>
<p>In this tutorial, you’ll learn what makes Vim so special. We’ll explore its commands, text filtering, and string manipulation capabilities to help you harness its true power.</p>
<h2 id="heading-what-well-cover">What we’ll cover:</h2>
<ol>
<li><p><a class="post-section-overview" href="#heading-text-editors-in-linux">Text Editors in Linux</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-how-to-open-the-vim-editor">How to Open the Vim Editor</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-modes-in-vim">Modes in Vim</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-basic-vim-commands">Basic Vim Commands</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-cut-copy-paste-and-delete-commands">Cut, Copy, Paste, and Delete Commands</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-search-and-replace-commands">Search and Replace Commands</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-how-to-read-files-using-more-and-less">How to Read Files using more and less</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-text-filters">Text Filters</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-text-summarization-tools-wc">Text Summarization Tool: wc</a></p>
</li>
</ol>
<h2 id="heading-text-editors-in-linux">Text Editors in Linux</h2>
<p>Linux provides a variety of text editors, each designed for different types of users – from beginners to advanced developers.</p>
<p>Editors like <strong>Nano</strong> are great for newcomers who need a simple, user-friendly experience in the terminal. Nano displays helpful commands at the bottom of the screen, making it easy to navigate without a steep learning curve.</p>
<p><strong>Gedit</strong>, the default editor for the GNOME desktop environment, offers a clean, graphical interface ideal for basic text editing. On the other hand, <strong>Kate</strong> caters to KDE desktop users and provides a more feature-rich experience, with multiple windows, syntax highlighting, and an integrated terminal.</p>
<p><strong>Emacs</strong> is a versatile and highly customizable editor that can be turned into an entire development environment, ideal for power users who want more than just a text editor.</p>
<p><strong>VS Code</strong> and <strong>Atom</strong> are modern, graphical editors that offer a rich set of features, including extensions, debugging tools, and Git integration, making them favorites among developers.</p>
<h3 id="heading-why-do-many-devs-prefer-vim">Why Do Many Devs Prefer Vim?</h3>
<p>Despite the wide range of text editors available in Linux, Vim stands out as the preferred choice for many users, especially those who need a lightweight, fast, and highly efficient editing environment.</p>
<p>Vim, an improved version of the classic Vi editor, is available on nearly every Linux distribution and can be used in both graphical and terminal-based environments. Its popularity stems from its exceptional speed and efficiency.</p>
<p>Vim is entirely keyboard-driven, allowing you to perform complex editing tasks quickly without the need for a mouse. This makes it incredibly useful for remote work, where you may have to rely on minimal system resources.</p>
<p>The power of Vim lies in its <strong>modal editing</strong> system, which separates the text input and command modes, which you’ll learn soon. This lets you execute precise actions with a few keystrokes. Whether you're navigating a file, searching for a string, or performing complex text manipulations, Vim enables you to do it all without taking your hands off the keyboard.</p>
<p>Because Vim (or Vi) is pre-installed on most Linux systems, it’s often the go-to option for developers and system administrators, who rely on its ubiquity and powerful features. In short, Vim’s combination of speed, versatility, and efficiency makes it the editor of choice for many Linux users looking to boost their productivity.</p>
<h2 id="heading-how-to-open-the-vim-editor">How to Open the Vim Editor</h2>
<p>Opening a file in Vim is straightforward and efficient. To start editing any file, simply use the following command in your terminal:</p>
<pre><code class="lang-bash">vim [filename]
</code></pre>
<p>Here, replace <code>[filename]</code> with the name of the file you want to open. If the file doesn't exist, Vim will create a new file with that name. Once executed, Vim will open the file and allow you to start editing right away.</p>
<p>Example:</p>
<pre><code class="lang-bash">vim data.txt <span class="hljs-comment"># A file that doesn't exist yet, so Vim creates a new file named data.txt</span>
</code></pre>
<p>When you execute the command <code>vim data.txt</code>, Vim opened a new file named <code>data.txt</code> because a file with this name did not previously exist in the current directory. In Vim, this is indicated by the message at the bottom of the editor, which reads: <code>data.txt [NEW]</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736790675984/98007e6c-cc90-42be-b853-f239f4f2e819.png" alt="Creating a new file using vim command" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>If the file you want to edit already exists, you can open it in Vim by using the same command. You’ll be able to see its contents and make edits as needed. If you don’t see the <code>[New]</code> message at the bottom (as shown for new files), it confirms the file already exists.</p>
<h2 id="heading-modes-in-vim">Modes in Vim</h2>
<p>Vim has several modes, but the most commonly used ones are:</p>
<ul>
<li><p><strong>Normal Mode (Command Mode)</strong> – Used for navigation and executing commands.</p>
</li>
<li><p><strong>Insert Mode</strong> – Used for typing and editing text.</p>
</li>
</ul>
<p>When you open a file in Vim, it starts in Command Mode by default. This mode allows you to navigate, execute commands, and perform various operations without directly modifying the text. To edit the text in the file, you need to switch to Insert Mode.</p>
<h3 id="heading-what-is-command-mode"><strong>What is Command Mode?</strong></h3>
<p>Command Mode is the default mode in Vim. In this mode, you can navigate through the file using the arrow keys and cut, copy, paste, or delete the content and execute commands like saving or quitting.</p>
<p>To switch to Command Mode from any other mode, press the <code>Esc</code> key.</p>
<p>Example: If you are in Insert Mode and need to return to Command Mode to save or navigate, press <code>Esc</code>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736791773096/298ef4f6-6fba-493d-b05c-0564290862a1.png" alt="Vim in command mode" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>In the above image, "hello.txt" 1L, 1B” indicates that the file <code>hello.txt</code> is open and is currently in Command Mode, which is the default mode when you open Vim. 1L Represents 1 line in the file (currently the file is empty, so there’s just one blank line). 1B Represents 1 byte (the file is currently empty)</p>
<h3 id="heading-what-is-insert-mode"><strong>What is Insert Mode?</strong></h3>
<p>Insert Mode allows you to edit or type text in the file, similar to a traditional text editor. You can insert new lines, modify existing text, and make changes directly.</p>
<p>Press <code>i</code> while in Command Mode. This switches to Insert Mode and places the cursor at the current position, allowing you to start typing.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736791793215/93d1ff39-9015-4209-8903-e29d1ccfb7c1.png" alt="Editor switched to INSERT mode" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>In the above image, “—INSERT—” indicates that the editor has been switched to Insert Mode, allowing you to type and edit text directly in the file.</p>
<p>Quick glance: When you open a file, always check the bottom of the terminal to determine your current mode. If the bottom line displays file-related information, you are in Command Mode. If the bottom line explicitly says <code>-- INSERT --</code>, you are in Insert Mode. If you want to go from <strong>Command Mode to Insert Mode:</strong> Press <code>i</code>. And from <strong>Insert Mode to Command Mode:</strong> Press <code>Esc</code>.</p>
<h2 id="heading-basic-vim-commands">Basic Vim Commands</h2>
<p>Below are some essential commands to help you manage files efficiently in Vim.</p>
<p><strong>Note:</strong> Before using these commands, ensure you're in command mode by pressing <code>Esc</code>.</p>
<h3 id="heading-1-save-changes"><strong>1. Save Changes</strong></h3>
<p>To save the changes made to a file, use the following command:</p>
<pre><code class="lang-bash">:w
</code></pre>
<p>This writes (saves) the current file without exiting Vim.</p>
<h3 id="heading-2-save-changes-and-quit"><strong>2. Save Changes and Quit</strong></h3>
<p>If you're done editing and want to save changes and exit Vim simultaneously, use:</p>
<pre><code class="lang-bash">:wq
</code></pre>
<p>This command writes the changes and then quits the editor.</p>
<h3 id="heading-3-quit-without-saving-changes"><strong>3. Quit Without Saving Changes</strong></h3>
<p>If you wish to exit without saving any changes, you can use:</p>
<pre><code class="lang-bash">:q
</code></pre>
<p>This command will close the file if no changes have been made since the last save.</p>
<h3 id="heading-4-force-quit-without-saving-changes"><strong>4. Force Quit Without Saving Changes</strong></h3>
<p>In case you've made changes to the file but want to exit without saving them, you can force quit with:</p>
<pre><code class="lang-bash">:q!
</code></pre>
<p>The <code>!</code> overrides any unsaved changes and closes the file immediately.</p>
<h2 id="heading-cut-copy-paste-and-delete-commands-plus-others"><strong>Cut, Copy, Paste, and Delete Commands (Plus Others)</strong></h2>
<h3 id="heading-how-to-position-the-cursor-for-text-manipulation"><strong>How to Position the Cursor for Text Manipulation</strong></h3>
<p>Before using any of the commands listed below (copy, cut, paste, and delete), it's important to understand where to place the cursor.</p>
<ul>
<li><p><strong>Copy (Yank), Cut, Delete:</strong> For most operations, the cursor needs to be placed <strong>at the starting point of the text</strong> you want to act upon. This means if you're copying or cutting a word, place the cursor at the <strong>beginning</strong> of the word. If you're working with a line, the cursor should be anywhere on that line. For paragraph-based operations, position the cursor anywhere within the paragraph.</p>
</li>
<li><p><strong>Paste:</strong> The text will be pasted at the cursor's <strong>current position</strong>. So, ensure your cursor is placed where you want the copied or cut content to appear.</p>
</li>
</ul>
<p>For example, Let’s say I have a file.txt that has the following content -</p>
<pre><code class="lang-bash"><span class="hljs-comment"># file.txt</span>
Hey readers,  
In this blog, we<span class="hljs-string">'re learning Vim. This file is for demonstration purposes,
where we'</span>ll explore various editing commands like cut, copy, paste, and delete. Let<span class="hljs-string">'s dive in!  

Vim is a powerful text editor that comes pre-installed on most Unix-based systems.
Mastering Vim can significantly boost your efficiency as a developer.  

To start with, let'</span>s learn some basic navigation and text manipulation commands.
Stay tuned as we <span class="hljs-built_in">break</span> down each <span class="hljs-built_in">command</span> with examples!
</code></pre>
<p>All the commands mentioned below will use this file as reference to explain examples.</p>
<h3 id="heading-1-copy-yank"><strong>1. Copy (Yank)</strong></h3>
<p>In Vim, copying is called "yanking." Use the following commands to copy text. The cursor's position is important to ensure the correct text is copied.</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Command</td><td>Description</td><td>Example</td></tr>
</thead>
<tbody>
<tr>
<td><code>yl</code></td><td>Copies a letter from the current cursor position (cursor must be on the left of the letter you want to copy)</td><td>If your cursor is on the left of <strong>"H"</strong> in <code>Hey readers,</code> and you type <code>yl</code>, Vim will copy <strong>"H"</strong> (only one character).</td></tr>
<tr>
<td><code>yw</code></td><td>Copies a word (cursor must be at the beginning of the word)</td><td>If your cursor is on the left of <strong>"blog,"</strong> in the sentence, Typing <code>yw</code> will copy <strong>"blog,"</strong> (including the comma).</td></tr>
<tr>
<td><code>yy</code></td><td>Copies the entire line (cursor can be anywhere on the line)</td><td>If your cursor is at any position on line 1 <strong>Hey readers,</strong> Typing <code>yy</code> will copy the entire line</td></tr>
<tr>
<td><code>2yy</code></td><td>Copies two lines, including the current cursor line (cursor can be anywhere on the first line)</td><td>If your cursor is at any position on line 1 <strong>Hey readers,</strong> Typing <code>2yy</code> will copy the entire line along with the next line.</td></tr>
<tr>
<td><code>y{</code></td><td>Copies the rest of the paragraph above the line where the cursor currently is (and including that line)</td><td>If your cursor is anywhere inside this paragraph 2 (Vim is a powerful text editor…), Typing <code>y{</code> will copy everything from the start of this paragraph up to the cursor position.</td></tr>
<tr>
<td><code>y}</code></td><td>Copies the rest of the paragraph below the line where the cursor currently is (and including that line)</td><td>If your cursor is anywhere inside this paragraph 2 (Vim is a powerful text editor…), Typing <code>y}</code> will copy everything from the current cursor position down to the end of the paragraph.</td></tr>
<tr>
<td><code>yG</code></td><td>Copies everything from the current line to the end of the file (cursor must be at the line where you want the copy operation to start)</td><td>If your cursor is at the beginning of this line “<strong>Vim is a powerful text editor…”,</strong> typing yG will copy this line and everything below it until the end of the file</td></tr>
</tbody>
</table>
</div><h3 id="heading-2-cut-change"><strong>2. Cut (Change)</strong></h3>
<p>Cutting in Vim is known as "changing" the text. The cut operation replaces the text. Just like with copying, the cursor's position is important when using cut commands.</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Command</td><td>Description</td><td>Example</td></tr>
</thead>
<tbody>
<tr>
<td><code>cl</code></td><td>Cuts a letter from the current cursor position (cursor must be on the left of the letter you want to cut)</td><td>If your cursor is on the <strong>"H"</strong> in <code>"Hey readers,"</code> and you type <code>cl</code>, Vim will delete <strong>"H"</strong> and switch to insert mode, allowing you to type a replacement.</td></tr>
<tr>
<td><code>cw</code></td><td>Cuts a word (cursor must be at the beginning of the word)</td><td>If your cursor is on the <strong>"blog,"</strong> in the sentence, typing <code>cw</code> will delete <strong>"blog,"</strong> (including the comma) and switch to insert mode, allowing you to type a replacement.</td></tr>
<tr>
<td><code>caw</code></td><td>Cuts a word along with trailing whitespace (cursor must be at the beginning of the word)</td><td>If your cursor is anywhere inside <strong>"blog,"</strong>, typing <code>caw</code> will delete <strong>" blog,"</strong> (including the preceding space) and switch to insert mode.</td></tr>
<tr>
<td><code>cc</code></td><td>Cuts the entire line (cursor can be anywhere on the line)</td><td>If your cursor is at any position on line 1 (<code>Hey readers,</code>), typing <code>cc</code> will delete the whole line and switch to insert mode.</td></tr>
<tr>
<td><code>2cc</code></td><td>Cuts two lines, including the current cursor line (cursor can be anywhere on the first line)</td><td>If your cursor is at any position on line 1 (<code>Hey readers,</code>), typing <code>2cc</code> will delete this line along with the next line and switch to insert mode.</td></tr>
<tr>
<td><code>c{</code></td><td>Cuts the text in the paragraph above the cursor’s location</td><td>If your cursor is anywhere inside paragraph 2 (<code>Vim is a powerful text editor…</code>), typing <code>c{</code> will delete everything from the cursor position to the start of the paragraph and switch to insert mode.</td></tr>
<tr>
<td><code>c}</code></td><td>Cuts the text in the paragraphs below the cursor’s location</td><td>If your cursor is anywhere inside paragraph 2 (<code>Vim is a powerful text editor…</code>), typing <code>c}</code> will delete everything from the cursor position to the end of the paragraph and switch to insert mode.</td></tr>
<tr>
<td><code>cG</code></td><td>Cuts everything from the current line to the end of the file (cursor must be at the line where you want the cut operation to start)</td><td>If your cursor is at the beginning of this line (<code>Vim is a powerful text editor…</code>), typing <code>cG</code> will delete this line and everything below it until the end of the file, then switch to insert mode.</td></tr>
</tbody>
</table>
</div><h3 id="heading-3-paste"><strong>3. Paste</strong></h3>
<p>To paste the copied or cut text, use the following commands. The pasted text will appear at the <strong>current cursor position</strong>.</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Command</td><td>Description</td></tr>
</thead>
<tbody>
<tr>
<td><code>p</code> (Lowercase)</td><td>Pastes the copied or cut text <strong>after</strong> the cursor</td></tr>
<tr>
<td><code>P</code> (Uppercase)</td><td>Pastes the copied or cut text <strong>before</strong> the cursor</td></tr>
</tbody>
</table>
</div><h3 id="heading-4-delete"><strong>4. Delete</strong></h3>
<p>Deleting text in Vim allows you to remove unwanted text while remaining in command mode. The cursor must be positioned correctly to delete the intended text. Once deleted, you can still paste the deleted text to a new location.</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Command</td><td>Description</td><td>Example</td></tr>
</thead>
<tbody>
<tr>
<td><code>dl</code></td><td>Deletes a letter from the current cursor position (cursor must be on the left of the letter you want to delete)</td><td>If your cursor is on <strong>"H"</strong> in <code>"Hey readers,"</code> and you type <code>dl</code>, Vim will delete <strong>"H"</strong>.</td></tr>
<tr>
<td><code>dw</code></td><td>Deletes a word (cursor must be at the beginning of the word)</td><td>If your cursor is on <strong>"blog,"</strong> in the sentence, typing <code>dw</code> will delete <strong>"blog,"</strong> (including the comma).</td></tr>
<tr>
<td><code>daw</code></td><td>Deletes a word along with trailing whitespace (cursor must be at the beginning of the word)</td><td>If your cursor is anywhere inside <strong>"blog,"</strong>, typing <code>daw</code> will delete <strong>" blog,"</strong> (including the preceding space).</td></tr>
<tr>
<td><code>dd</code></td><td>Deletes the entire line (cursor can be anywhere on the line)</td><td>If your cursor is at any position on line 1 (<code>Hey readers,</code>), typing <code>dd</code> will delete the whole line.</td></tr>
<tr>
<td><code>2dd</code></td><td>Deletes two lines, including the current cursor line (cursor can be anywhere on the first line)</td><td>If your cursor is at any position on line 1 (<code>Hey readers,</code>), typing <code>2dd</code> will delete this line along with the next line.</td></tr>
<tr>
<td><code>d{</code></td><td>Deletes the paragraph above the cursor (cursor can be anywhere in the paragraph you want to delete)</td><td>If your cursor is anywhere inside paragraph 2 (<code>Vim is a powerful text editor…</code>), typing <code>d{</code> will delete everything from the cursor position to the start of the paragraph.</td></tr>
<tr>
<td><code>d}</code></td><td>Deletes the paragraph below the cursor (cursor can be anywhere in the paragraph you want to delete)</td><td>If your cursor is anywhere inside paragraph 2 (<code>Vim is a powerful text editor…</code>), typing <code>d}</code> will delete everything from the cursor position to the end of the paragraph.</td></tr>
<tr>
<td><code>dG</code></td><td>Deletes everything from the current line to the end of the file (cursor must be at the line where you want the delete operation to start)</td><td>If your cursor is at the beginning of this line (<code>Vim is a powerful text editor…</code>), typing <code>dG</code> will delete this line and everything below it until the end of the file.</td></tr>
</tbody>
</table>
</div><h3 id="heading-5-other-useful-commands"><strong>5. Other Useful Commands</strong></h3>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Commands</td><td>Description</td></tr>
</thead>
<tbody>
<tr>
<td><code>gg</code></td><td>Moves the cursor to the first line of the file</td></tr>
<tr>
<td><code>G</code></td><td>Moves the cursor to the last line of the file</td></tr>
<tr>
<td><code>:se nu</code></td><td>Sets line numbers in the file</td></tr>
<tr>
<td><code>:se nonu</code></td><td>Removes line numbers from the file</td></tr>
<tr>
<td><code>:u</code></td><td>Undoes the last action</td></tr>
<tr>
<td><code>:10</code></td><td>Jumps to line 10 (for example)</td></tr>
</tbody>
</table>
</div><p>Note that <strong>Delete</strong> removes text but doesn’t store it in the system clipboard by default. The text goes into Vim’s unnamed register, meaning it can be pasted within Vim but not outside it. <strong>Cut</strong> explicitly stores text in the clipboard so you can paste it outside Vim as well.</p>
<h2 id="heading-search-and-replace-commands"><strong>Search and Replace Commands</strong></h2>
<p>Vim provides powerful search and replace functionality that allows you to find specific words or patterns and replace them efficiently. Understanding how to search and replace text is key to improving your productivity when editing large files.</p>
<p>Below is a breakdown of the various search and replace commands in Vim.</p>
<h3 id="heading-search-commands"><strong>Search Commands</strong></h3>
<ul>
<li><p><strong>Search Forward</strong> (<code>/</code>): When you want to search for a word or pattern below the cursor, use the <code>/</code> command. This will search forward in the file.</p>
</li>
<li><p><strong>Search Backward</strong> (<code>?</code>): Similarly, if you want to search for a word or pattern above the cursor, use the <code>?</code> command. This will search backward in the file.</p>
</li>
</ul>
<p>After performing a search, you can navigate through the search results:</p>
<ul>
<li><p><code>n</code>: Go to the next match in the same direction (forward if <code>/</code>, backward if <code>?</code>).</p>
</li>
<li><p><code>N</code>: Go to the previous match in the opposite direction (backward if <code>/</code>, forward if <code>?</code>).</p>
</li>
</ul>
<h3 id="heading-replace-commands"><strong>Replace Commands</strong></h3>
<p>Once you've located the word or pattern you want to replace, Vim provides several commands for replacing text.</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Command (In command mode)</td><td>Description</td></tr>
</thead>
<tbody>
<tr>
<td><code>/search_word</code></td><td>Searches for the given word and moves the cursor to its first occurrence below the current cursor position.</td></tr>
<tr>
<td><code>:s/search_word/replace_word</code></td><td>Replaces the first occurrence of <code>search_word</code> with <code>replace_word</code> in the current line.</td></tr>
<tr>
<td><code>:s/search_word/replace_word/g</code></td><td>Replaces all occurrences of <code>search_word</code> with <code>replace_word</code> in the current line.</td></tr>
<tr>
<td><code>:%s/search_word/replace_word</code></td><td>Replaces the first occurrence of <code>search_word</code> with <code>replace_word</code> in the entire file.</td></tr>
<tr>
<td><code>:%s/search_word/replace_word/g</code></td><td>Replaces all occurrences of <code>search_word</code> with <code>replace_word</code> in the entire file.</td></tr>
</tbody>
</table>
</div><p>Here’s an example:</p>
<p>In Vim, the <code>/Tanishka</code> pattern searches for an exact, case-sensitive match of the word "Tanishka."</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736795075490/1ecbc6f4-65ef-46a9-841d-dbb3251f8ec7.png" alt="1ecbc6f4-65ef-46a9-841d-dbb3251f8ec7" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>To replace "Tanishka" with another word, like "Linux," you can use the substitution command like this: <code>:s/Tanishka/Linux</code>:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736794982127/c9dffdba-c250-4601-8e3b-950d875908f8.png" alt="c9dffdba-c250-4601-8e3b-950d875908f8" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>By default, this command replaces only the first occurrence of "Tanishka" in the line where the cursor is located.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736794997175/9831423d-4aab-43a1-9b06-408fb5dd4828.png" alt="9831423d-4aab-43a1-9b06-408fb5dd4828" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>If you want to replace all occurrences of "Tanishka" in the same line, you need to add the <code>g</code> (global) flag after the replacement string like this: <code>:s/Tanishka/Linux/g</code>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736795009744/c53d0de2-b7b4-4154-baaa-3d28fb3c29db.png" alt="c53d0de2-b7b4-4154-baaa-3d28fb3c29db" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>This ensures that every instance of "Tanishka" in the current line is replaced with "Linux."</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736795017539/dac817e5-8130-44d4-8f09-d887e42cc859.png" alt="dac817e5-8130-44d4-8f09-d887e42cc859" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>Similarly, the <code>%</code> symbol is used to specify the <strong>entire file</strong> when performing a substitution. Here's how it works in combination with the substitution command:</p>
<ol>
<li><p><strong>Replace the first occurrence in each line of the file:</strong></p>
<ul>
<li><code>:%s/Tanishka/Linux</code>: This command replaces only the first occurrence of "Tanishka" in each line of the file.</li>
</ul>
</li>
<li><p><strong>Replace all occurrences in the entire file:</strong></p>
<ul>
<li><code>:%s/Tanishka/Linux/g</code>: The addition of the <code>g</code> (global) flag ensures that all occurrences of "Tanishka" in every line of the file are replaced with "Linux."</li>
</ul>
</li>
</ol>
<h2 id="heading-how-to-read-files-using-more-and-less"><strong>How to Read Files using</strong> <code>more</code> <strong>and</strong> <code>less</code></h2>
<h3 id="heading-the-cat-command">The <code>cat</code> command</h3>
<p>The cat command is often used to read file content.</p>
<p>For example:</p>
<pre><code class="lang-bash">cat file.txt <span class="hljs-comment"># Displays content of file</span>
</code></pre>
<p>While the <code>cat</code> command is a straightforward tool for viewing file contents, its simplicity often falls short when working with large files or when precise navigation is required. That’s where the <code>more</code> and <code>less</code> commands come into play, offering enhanced functionality for viewing and navigating text efficiently.</p>
<h3 id="heading-the-more-command">The <code>more</code> Command</h3>
<p>The <code>more</code> command allows you to view files one screen at a time, making it a significant upgrade from <code>cat</code> when dealing with large files. But it comes with limitations in terms of backward navigation and advanced features.</p>
<p>Here’s the syntax for <code>more</code>:</p>
<pre><code class="lang-bash">more [FILENAME]
</code></pre>
<p>And here’s an example:</p>
<pre><code class="lang-bash">more file.txt <span class="hljs-comment"># Displays content of file.txt one page at a time</span>
</code></pre>
<p>Keys used while viewing:</p>
<ol>
<li><p>Spacebar: Moves forward by one page</p>
</li>
<li><p>Enter: Moves forward by one line</p>
</li>
<li><p>b: Moves back by one page</p>
</li>
<li><p>q: Quit and exit file content</p>
</li>
</ol>
<h3 id="heading-the-less-command">The <code>less</code> Command</h3>
<p>The <code>less</code> command is often considered a superior alternative to <code>more</code> due to its advanced navigation capabilities and flexibility. Unlike <code>more</code>, <code>less</code> allows both forward and backward navigation, making it ideal for reviewing large files or logs.</p>
<p>Here’s its syntax:</p>
<pre><code class="lang-bash">less [FILENAME]
</code></pre>
<p>And here’s an example:</p>
<pre><code class="lang-bash">less file.txt <span class="hljs-comment"># Displays content of file.txt one page at a time</span>
</code></pre>
<p>Keys used while viewing:</p>
<ol>
<li><p>Spacebar: Moves forward by one page</p>
</li>
<li><p>Enter: Moves forward by one line</p>
</li>
<li><p>b: Moves back by one page</p>
</li>
<li><p>Up/Down arrow key: Moves up or down by one line</p>
</li>
<li><p>q: Quit and exit less</p>
</li>
</ol>
<p>The only major difference between the <code>more</code> and <code>less</code> commands is that the less command allows bidirectional navigation, so it’s typically more convenient to use.</p>
<h2 id="heading-text-filters"><strong>Text Filters</strong></h2>
<p>A <strong>text filter</strong> in Linux is a command-line utility that processes text data by modifying, extracting, or formatting it before outputting the result.</p>
<h3 id="heading-horizontal-filters">Horizontal filters</h3>
<p>Horizontal filtering focuses on extracting, manipulating, or displaying specific lines of a file or command output. Common tools include <code>head</code>, <code>tail</code>, and <code>grep</code>.</p>
<ol>
<li><p><code>head</code>: The head command displays the first few lines of a file. By default, it shows the first 10 lines. Here’s its syntax:</p>
<pre><code class="lang-bash"> head [OPTIONS] [FILENAME]
</code></pre>
<p> And here’s an example of how to use it:</p>
<pre><code class="lang-bash"> head file.txt <span class="hljs-comment"># Displays first ten lines from file.txt</span>
 head -n 5 file.txt <span class="hljs-comment"># Displays first five lines from file.txt</span>
</code></pre>
</li>
<li><p><code>tail</code>: The tail command displays the last few lines of a file. By default, it shows the last 10 lines. Here’s its syntax:</p>
<pre><code class="lang-bash"> tail [OPTIONS] [FILENAME]
</code></pre>
<p> And here’s an example:</p>
<pre><code class="lang-bash"> tail file.txt <span class="hljs-comment"># Displays last ten lines from file.txt</span>
 tail -n 5 file.txt <span class="hljs-comment"># Displays last five lines from file.txt</span>
</code></pre>
</li>
<li><p><code>grep</code>: The grep command searches for patterns within a file or input. It filters out lines that match a given pattern. Here’s its syntax:</p>
<pre><code class="lang-bash"> grep [OPTIONS] [PATTERN] [FILENAME]
</code></pre>
<p> Options:</p>
<ul>
<li><p><code>-i</code>: Case-insensitive search.</p>
</li>
<li><p><code>-v</code>: Invert the match (exclude matching lines).</p>
</li>
<li><p><code>-n</code>: Show line numbers of matches.</p>
</li>
</ul>
</li>
</ol>
<p>    Example</p>
<pre><code class="lang-bash">    grep Tanishka data.txt <span class="hljs-comment"># Displays lines that have 'Tanishka' in them</span>
    grep -i Tanishka data.txt <span class="hljs-comment"># Displays lines that have 'Tanishka' irrespective of case</span>
    grep -v Tanishka data.txt <span class="hljs-comment"># Displays lines that do not have 'Tanishka' in them</span>
    grep -n Tanishka data.txt <span class="hljs-comment"># Displays lines that have 'Tanishka' in them along with number line</span>
</code></pre>
<h3 id="heading-vertical-filters">Vertical Filters</h3>
<ol>
<li><p><code>cut</code>: The cut command displays selected parts of lines from each file based on delimiters, byte positions, or character fields. Here’s its syntax:</p>
<pre><code class="lang-bash"> cut [OPTION] [FILENAME]
</code></pre>
<p> It also comes with various options:</p>
<ul>
<li><p><code>-c</code>: Extract specific characters.</p>
</li>
<li><p><code>-b</code>: Extract specific bytes.</p>
</li>
<li><p><code>-d</code>: Specify a custom delimiter (default is tab).</p>
<ul>
<li><code>cut -d ":" -f 2 file.txt</code> → Second field separated by <code>:</code>.</li>
</ul>
</li>
<li><p><code>-f</code>: Extract specific fields.</p>
<ul>
<li><code>cut -d "," -f 1,3 file.csv</code> → Fields 1 and 3 from a CSV.</li>
</ul>
</li>
</ul>
</li>
</ol>
<p>    Example:</p>
<pre><code class="lang-bash">    cut -c 1-10 Sample.txt <span class="hljs-comment"># Displays characters from position 1 to 10</span>
    cut -c 5 Sample.txt <span class="hljs-comment"># Displays character at position 5</span>
    cut -c 3,5 Sample.txt <span class="hljs-comment"># Displays characters from position 3 and 5 only</span>
    cut -d <span class="hljs-string">" "</span> -f 1 Sample.txt <span class="hljs-comment"># Displays first field separated by a space</span>
    cut -d <span class="hljs-string">" "</span> -f 2 Sample.txt <span class="hljs-comment"># Displays second field separated by a space</span>
    cut -d <span class="hljs-string">" "</span> -f 3 Sample.txt <span class="hljs-comment"># Displays third field separated by a space</span>
    cut -d <span class="hljs-string">" "</span> -f 1-3 Sample.txt <span class="hljs-comment"># Displays first to third fields separated by a space</span>
    cut -d <span class="hljs-string">" "</span> -f 1,3 Sample.txt <span class="hljs-comment"># Displays first and third fields separated by a space</span>
    cut -d <span class="hljs-string">":"</span> -f 5 /etc/passwd <span class="hljs-comment"># Displays fifth field separated by : in /etc/passwd</span>
</code></pre>
<h2 id="heading-text-summarization-tool-wc"><strong>Text Summarization Tool:</strong> <code>wc</code></h2>
<p>The <code>wc</code> (word count) command is used to display the number of lines, words, characters, or bytes in a file or input. It is a simple yet powerful utility you can use to summarize text content.</p>
<p>Here’s its syntax:</p>
<pre><code class="lang-bash">wc [OPTION] [FILENAME]
</code></pre>
<p>And here are its options:</p>
<ul>
<li><p><code>-l</code>: Displays the number of lines.</p>
</li>
<li><p><code>-w</code>: Displays the number of words.</p>
</li>
<li><p><code>-c</code>: Displays the number of bytes.</p>
</li>
<li><p><code>-m</code>: Displays the number of characters (useful for multibyte characters).</p>
</li>
<li><p><code>-L</code>: Displays the length of the longest line.</p>
</li>
</ul>
<p>Example:</p>
<pre><code class="lang-bash">wc Sample.txt <span class="hljs-comment"># Displays line count, word count, and byte count in Sample.txt</span>
wc -w Sample.txt <span class="hljs-comment"># Displays number of words in Sample.txt</span>
wc -l Sample.txt <span class="hljs-comment"># Displays number of lines in Sample.txt</span>
wc -L Sample.txt <span class="hljs-comment"># Displays number of characters in longest line in Sample.txt</span>

wc -c Sample.txt <span class="hljs-comment"># Displays number of bytes in Sample.txt (Actual storage size)</span>
wc -m Sample.txt <span class="hljs-comment"># Displays number of characters in Sample.txt (Actual number of characters regardless of enoing)</span>

<span class="hljs-comment"># ABCD😄</span>
wc -c above.txt <span class="hljs-comment"># "ABCD" = 4 bytes + "😄" = 4 bytes. 4 + 4 = 8 bytes</span>
wc -m above.txt <span class="hljs-comment"># "ABC" = 4 + "😄" = 1 byte. 4 + 1 = 5 bytes</span>
</code></pre>
<h2 id="heading-final-words">Final Words</h2>
<p>In this article, we covered the basics of using Vim, a powerful and flexible text editor. We started with how to open a file in Vim and then you learned about its modes. You also learned how to navigate through files, edit text, and use features like search and replace to save time. We also explored a helpful summarization tool.</p>
<p>If you're new to Linux and want to build a strong foundation, check <a target="_blank" href="https://www.freecodecamp.org/news/guide-to-rhel-linux-basics/">my previous article</a> where I cover the basics of Linux, including essential commands and tips for beginners. It’s a perfect starting point to complement what you’ve learned about Vim here!</p>
<p>Keep practising these commands, and soon they'll become second nature to you. Mastery comes with repetition, so continue experimenting and applying these fundamentals in real-world scenarios.</p>
<p>Stay tuned for more articles. Get ready to take your RHEL skills to the next level.</p>
<p><a target="_blank" href="https://linktr.ee/tanishkamakode">Let’s connect!</a></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Mastering VIM: Your Guide to Efficient Text Editing ]]>
                </title>
                <description>
                    <![CDATA[ VIM is a highly configurable text editor that enables efficient text editing. It's favored by many developers and system administrators for its powerful capabilities and extensive customization options. We just published a course on the freeCodeCamp.... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/mastering-vim-your-guide-to-efficient-text-editing/</link>
                <guid isPermaLink="false">6679960799a6253dafb282f6</guid>
                
                    <category>
                        <![CDATA[ vim ]]>
                    </category>
                
                    <category>
                        <![CDATA[ youtube ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Beau Carnes ]]>
                </dc:creator>
                <pubDate>Mon, 24 Jun 2024 15:51:35 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1719244279807/32ef1ce5-423b-4762-b0fa-5f6420d67788.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>VIM is a highly configurable text editor that enables efficient text editing. It's favored by many developers and system administrators for its powerful capabilities and extensive customization options.</p>
<p>We just published a course on the freeCodeCamp.org YouTube channel that will help you master the VIM editor. Whether you're new to VIM or looking to deepen your understanding, this course will equip you with the essential skills to leverage VIM effectively in your development workflow. Andrew Brown from ExamPro developed this course.</p>
<p>By the end of this course, you will understand the historical context and evolution of VIM, gain proficiency in its core commands and modes, learn how to customize VIM to suit your personal workflow, explore advanced features, including plugins and scripting with VimScript, and develop the ability to integrate VIM into various development environments.</p>
<p>VIM is known for its steep learning curve, and it's not uncommon to hear about the frustrations of beginners. The initial challenges, however, give way to a powerful, efficient, and highly productive editing experience. This course aims to smooth your learning curve and transform your VIM experience from daunting to delightful.</p>
<p>Below you will find a description of the core sections in this course, starting with the Prelude and then covering core commands.</p>
<h1 id="heading-prelude">Prelude</h1>
<h3 id="heading-pdp-7-and-the-birth-of-unix">PDP-7 and the Birth of Unix</h3>
<p>To truly understand VIM, we need to start with the PDP-7, a minicomputer from the 1960s where the Unix operating system was born. The development of Unix led to the creation of various text editors that served as precursors to VIM. Unix introduced a host of command-line tools foundational to modern computing, and emulating Unix 1 allows us to appreciate the environment in which early text editors like Ed and Ex were developed.</p>
<h3 id="heading-what-is-ed-and-ex">What is Ed and EX?</h3>
<p>Ed is one of the earliest text editors for Unix, known for its simplicity and command-based interface. Engaging with Ed directly helps us understand its command structure and functionality, laying the groundwork for subsequent editors.</p>
<p>Ex, on the other hand, extended Ed's capabilities, adding more features and improving user interaction. Following along with Ex, we can experience its enhancements and see how it set the stage for Vi, the next evolution in text editing.</p>
<h3 id="heading-what-is-vi">What is VI?</h3>
<p>Vi, or visual editor, was a significant leap forward, offering a screen-oriented approach to text editing. Exploring Vi's interface and basic commands reveals why it became so popular among developers.</p>
<p>Vi was further improved into VIM (Vi IMproved), which builds upon Vi with extensive enhancements, making it a powerful editor for modern development. Starting with Vimtutor, an interactive tutorial, and exploring the built-in help system is an excellent way to get acquainted with VIM.</p>
<h3 id="heading-evolution-and-versions-of-vim">Evolution and Versions of VIM</h3>
<p>Understanding the different versions of VIM and their evolution over time is crucial for appreciating its current capabilities. Experimenting with various VIM versions allows us to appreciate their differences and how VIM has adapted to meet the needs of developers.</p>
<p>Additionally, learning to install and use GVim, the graphical version of VIM, offers a more accessible introduction for new users.</p>
<h3 id="heading-customization-and-plugins">Customization and Plugins</h3>
<p>Discovering VimScript, the scripting language used to extend VIM's functionality, enables you to automate tasks and create custom commands.</p>
<p>Diving into VIM's configuration files, we learn to personalize our editing environment. Using plugin managers, we can extend VIM's capabilities with community-developed plugins.</p>
<p>Janus, a popular VIM distribution that comes pre-configured with a suite of plugins and settings, offers a streamlined setup. Installing and experimenting with Janus, and learning to use Vim Plug, a minimalist plugin manager, helps us manage VIM plugins efficiently.</p>
<p>NeoVIM, a modern refactor of VIM designed to improve performance and extendibility, offers enhanced features and improved user experience. Exploring NeoVIM and its capabilities further enhances our understanding of VIM's versatility.</p>
<p>Finally, Vimium, a browser extension that brings VIM-style navigation to the web, showcases the influence of VIM's keybindings beyond traditional text editing.</p>
<h1 id="heading-vim-core-commands">VIM Core Commands</h1>
<h3 id="heading-integration-with-ides">Integration with IDEs</h3>
<p>Learning how VIM can be integrated into other Integrated Development Environments (IDEs) combines VIM's efficiency with the features of modern IDEs. Installing VIM extensions in popular IDEs like Visual Studio Code allows us to use VIM's editing capabilities within a familiar environment.</p>
<h3 id="heading-basic-navigation-and-editing">Basic Navigation and Editing</h3>
<p>Mastering the home row keys, which are central to VIM's command structure, increases our editing speed and efficiency. VIM operates in different modes, each designed for specific types of tasks, and understanding and switching between these modes is crucial for effective use. Practicing normal, insert, visual, and command-line modes helps us become comfortable with VIM's modal nature.</p>
<h3 id="heading-file-and-motion-commands">File and Motion Commands</h3>
<p>Learning commands for opening, saving, and closing files is essential for managing our work in VIM. Motion commands allow us to navigate text efficiently, with directional motions (h, j, k, l) being the basic movements used to navigate text.</p>
<p>Practicing using directional motion commands to move through text quickly, as well as learning goto motions for jumping to specific locations within the file, enhances our text navigation skills.</p>
<p>Word motions allow for navigation by words, making it easier to move through text, and joining lines of text seamlessly is a useful command for text formatting.</p>
<p>Commands to quickly navigate to the start or end of a line, the replace command for quick substitutions of text, and undo and redo commands for managing changes effectively are all part of our core VIM toolkit.</p>
<h3 id="heading-advanced-editing">Advanced Editing</h3>
<p>The change command allows us to replace portions of text efficiently, while the delete command helps us remove text quickly.</p>
<p>Yanking (copying) and pasting text are fundamental operations in VIM, and learning insert and append commands allows us to add text in different ways.</p>
<p>The line insert command for inserting lines of text efficiently, the find command for locating specific text quickly, and the substitute command for replacing text patterns are all advanced editing techniques that increase our efficiency.</p>
<p>The leader key is a customizable shortcut that simplifies complex command sequences, and mastering visual mode for text selection and manipulation is essential for effective editing.</p>
<p>Indentation commands help us format code and text properly, and window splitting allows us to work with multiple files or views simultaneously.</p>
<p>Understanding buffers for managing multiple open files, and registers for storing and retrieving text snippets for reuse, rounds out our advanced editing capabilities.</p>
<h1 id="heading-conclusion">Conclusion</h1>
<p>By the end of this course, you'll have a solid foundation in VIM, enabling you to use it effectively in your development work. Watch the full course on the <a target="_blank" href="https://youtu.be/JYNA9j8SXs4">freeCodeCamp.org YouTube channel</a> (4-hour watch).</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/JYNA9j8SXs4" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Vim Key Bindings – Vim Keys List Reference ]]>
                </title>
                <description>
                    <![CDATA[ Understanding Vim key bindings is crucial for navigating and editing text efficiently in Vim or Vim-based text editors like Neovim.  In this article, we'll explore the most common Vim key bindings that will help you navigate your text editor seamless... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/vim-key-bindings-reference/</link>
                <guid isPermaLink="false">66bb88320eaca026d8cfa5bd</guid>
                
                    <category>
                        <![CDATA[ cheatsheet ]]>
                    </category>
                
                    <category>
                        <![CDATA[ reference ]]>
                    </category>
                
                    <category>
                        <![CDATA[ vim ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Sahil ]]>
                </dc:creator>
                <pubDate>Tue, 06 Feb 2024 09:28:01 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2024/02/Neon-Green-Bold-Quote-Motivational-Tweet-Instagram-Post-4-.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Understanding Vim key bindings is crucial for navigating and editing text efficiently in Vim or Vim-based text editors like Neovim. </p>
<p>In this article, we'll explore the most common Vim key bindings that will help you navigate your text editor seamlessly.</p>
<h2 id="heading-table-of-content">Table of Content</h2>
<ul>
<li><a class="post-section-overview" href="#heading-vim-modes">Vim Modes</a></li>
<li><a class="post-section-overview" href="#heading-how-to-navigate-using-vim-key-bindings">How to Navigate using Vim Key Bindings</a></li>
<li><a class="post-section-overview" href="#heading-how-to-edit-text-in-normal-mode">How to Edit Text in Normal Mode</a></li>
<li><a class="post-section-overview" href="#heading-insert-mode">Insert Mode</a></li>
<li><a class="post-section-overview" href="#heading-visual-mode">Visual Mode</a></li>
<li><a class="post-section-overview" href="#heading-more-navigation-commands">More Navigation Commands</a></li>
<li><a class="post-section-overview" href="#heading-programming-specific-vim-key-bindings">Programming Specific Key Bindings</a></li>
<li><a class="post-section-overview" href="#heading-conclusion">Conclusion</a></li>
</ul>
<h2 id="heading-vim-modes">Vim Modes</h2>
<p>Vim operates in distinct modes, each designed for specific tasks:</p>
<ul>
<li><strong>Normal Mode</strong>: Default state for efficient movement, deletion, searching, and more.</li>
<li><strong>Insert Mode</strong>: Allows you to type text directly into your file.</li>
<li><strong>Visual Mode</strong>: Enables text selection for manipulation.</li>
</ul>
<h2 id="heading-how-to-navigate-using-vim-key-bindings">How to Navigate using Vim Key Bindings</h2>
<h3 id="heading-basic-movement">Basic Movement</h3>
<p>Here are some basic movement keys:</p>
<pre><code class="lang-plaintext">h  --&gt; move left
j  --&gt; move down
k  --&gt; move up
l  --&gt; move right
</code></pre>
<h3 id="heading-moving-to-top-and-bottom">Moving to Top and Bottom</h3>
<p>You can use these keys to move to the top or bottom of the page:</p>
<pre><code class="lang-plaintext">gg  --&gt; Move to the first line of the page
G   --&gt; Move to the last line of the page
</code></pre>
<h3 id="heading-moving-to-a-specific-line">Moving to a Specific Line</h3>
<p>You can move to a specific using <code>:</code> followed by the line number:</p>
<pre><code class="lang-plaintext">:number   --&gt; Go to the line number
</code></pre>
<h3 id="heading-moving-within-a-line">Moving Within a Line</h3>
<p>You can use these keys move to the start or end of a line:</p>
<pre><code class="lang-plaintext">$  --&gt; Go to the end of the line
0  --&gt; Go to the start of the line
</code></pre>
<h3 id="heading-moving-through-words">Moving Through Words</h3>
<p>Here are some keys for moving through lines of text:</p>
<pre><code class="lang-plaintext">b  --&gt; Go to the previous word
w  --&gt; Go to the next word
</code></pre>
<h2 id="heading-how-to-edit-text-in-normal-mode">How to Edit Text in Normal Mode</h2>
<h3 id="heading-deletion-and-copying">Deletion and Copying</h3>
<p>You can delete or copy characters using these keys:</p>
<pre><code class="lang-plaintext">x   --&gt; Delete the character under the cursor
dd  --&gt; Delete the entire line
yy  --&gt; Copy (yank) the entire line
p   --&gt; Paste the previously deleted or copied text after the cursor
</code></pre>
<h3 id="heading-undo-and-redo">Undo and Redo</h3>
<pre><code class="lang-plaintext">u          --&gt; Undo the last action
Ctrl + r   --&gt; Redo the undone action
</code></pre>
<h3 id="heading-searching-and-replacing">Searching and Replacing</h3>
<pre><code class="lang-plaintext">/              --&gt; Start searching forward
?              --&gt; Start searching backward
:s/old/new/g   --&gt; Replace all occurrences of "old" with "new" in the entire file
</code></pre>
<h2 id="heading-insert-mode">Insert Mode</h2>
<p>In Insert mode, you can type text directly into your file. Here are some key bindings to help you navigate in this mode:</p>
<pre><code class="lang-plaintext">Esc   --&gt; Return to Normal Mode
i     --&gt; Start inserting text before the cursor
a     --&gt; Start inserting text after the cursor
o     --&gt; Open a new line below the current line and start inserting text
</code></pre>
<h2 id="heading-visual-mode">Visual Mode</h2>
<p>Visual mode is useful for selecting and manipulating text visually. Here are some key bindings:</p>
<pre><code class="lang-plaintext">v          --&gt; Start character-wise visual mode
V          --&gt; Start line-wise visual mode
Ctrl + v   --&gt; Start block-wise visual mode
d          --&gt; Delete the selected text
y          --&gt; Copy (yank) the selected text
p          --&gt; Paste the copied text after the cursor
</code></pre>
<h2 id="heading-more-navigation-commands">More Navigation Commands</h2>
<h3 id="heading-scrolling">Scrolling</h3>
<pre><code class="lang-plaintext">Ctrl + u   --&gt; Move half a screen up
Ctrl + d   --&gt; Move half a screen down
Ctrl + b   --&gt; Move one full screen up
Ctrl + f   --&gt; Move one full screen down
</code></pre>
<h3 id="heading-jumping-between-words-and-paragraphs">Jumping between Words and Paragraphs</h3>
<pre><code class="lang-plaintext">(  --&gt; Jump to the beginning of the previous sentence
)  --&gt; Jump to the beginning of the next sentence
{  --&gt; Jump to the beginning of the previous paragraph
}  --&gt; Jump to the beginning of the next paragraph
</code></pre>
<p>These commands provide a comprehensive overview of the essential Vim key bindings for efficient navigation and text manipulation.</p>
<h2 id="heading-programming-specific-vim-key-bindings">Programming-Specific Vim Key Bindings</h2>
<h3 id="heading-moving-between-functions">Moving Between Functions</h3>
<p>In a code file, navigating between functions is a common task. Vim makes it efficient with these keys:</p>
<pre><code class="lang-plaintext">]]  --&gt; Move to the beginning of the next function
[[  --&gt; Move to the beginning of the previous function
</code></pre>
<p>These commands are invaluable for quickly jumping between different parts of your code.</p>
<h3 id="heading-indentation">Indentation</h3>
<p>Maintaining consistent code indentation is crucial. Vim enhances this with these keys:</p>
<pre><code class="lang-plaintext">&gt;&gt;  --&gt; Indent the current line to the right
&lt;&lt;  --&gt; Indent the current line to the left
</code></pre>
<p>Effortlessly adjust the indentation to adhere to coding standards and improve code readability.</p>
<h3 id="heading-folding">Folding</h3>
<p>Code folding aids in managing large files. Vim provides powerful folding commands:</p>
<pre><code class="lang-plaintext">zf{motion}  --&gt; Create a fold (replace {motion} with a movement command)
zo          --&gt; Open a fold
zc          --&gt; Close a fold
zr          --&gt; Reduce folding level throughout the file
zm          --&gt; Increase folding level throughout the file
</code></pre>
<p>Use folding to collapse and expand sections, this makes it easier to focus on specific parts of your code.</p>
<h3 id="heading-code-commenting">Code Commenting</h3>
<p>Efficiently comment and uncomment code with:</p>
<pre><code class="lang-plaintext">gcc  --&gt; Comment/uncomment the current line
gc{motion}  --&gt; Comment/uncomment the lines covered by {motion}
</code></pre>
<p>Speed up the commenting process and maintain code documentation effortlessly.</p>
<h3 id="heading-matching-parentheses">Matching Parentheses</h3>
<p>Effortlessly navigate and understand code structure with:</p>
<pre><code class="lang-plaintext">%  --&gt; Move to the matching parenthesis, bracket, or brace
</code></pre>
<p>This makes it easier to navigate complex code by quickly jumping between corresponding code blocks.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>In essence, mastering Vim key bindings unlocks a world of efficient text editing. From basic movements to advanced coding tasks, Vim's modes and commands streamline navigation and manipulation. </p>
<p>By embracing these key bindings, you'll enhance productivity and enjoy a more seamless editing experience. Happy coding in Vim!</p>
<p>If you have any feedback, then you can DM me on <a target="_blank" href="https://twitter.com/introvertedbot">Twitter</a> or <a target="_blank" href="https://www.linkedin.com/in/sahil-mahapatra/">LinkedIn</a>.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Why Vim Is More than Just an Editor – Vim Language, Motions, and Modes Explained ]]>
                </title>
                <description>
                    <![CDATA[ Throughout my time as a developer, I've used VS Code, Sublime, Notepad++, TextMate, and others. But shortcuts like cmd(+shift)+end and jumping with option+arrow-keys from word to word needed to be faster at some point. I was hitting my limits. Everyt... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/vim-language-and-motions-explained/</link>
                <guid isPermaLink="false">66d4614b3a8352b6c5a2ab17</guid>
                
                    <category>
                        <![CDATA[ editor ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Productivity ]]>
                    </category>
                
                    <category>
                        <![CDATA[ General Programming ]]>
                    </category>
                
                    <category>
                        <![CDATA[ vim ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Simon Späti ]]>
                </dc:creator>
                <pubDate>Tue, 14 Feb 2023 19:52:55 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/02/using-neo-vim-feature-freecode-3.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Throughout my time as a developer, I've used VS Code, Sublime, Notepad++, TextMate, and others. But shortcuts like <code>cmd(+shift)+end</code> and jumping with <code>option+arrow-keys</code> from word to word needed to be faster at some point.</p>
<p>I was hitting my limits. Everything I was doing I did decently fast, but I didn’t get any faster.</p>
<p>I've since learned that Vim is the only editor that you get faster using with time.</p>
<p><a target="_blank" href="https://www.vim.org/">Vim</a> is based solely on shortcuts. When I discovered that and played around a bit, I felt numb and a little stupid, having not learned the shortcuts (called Vim language) much earlier in my career.</p>
<p>I realized there was a keystroke to get to any specific position I wanted to jump. It was like a game, seeing if I could use fewer shortcuts to accomplish a particular edit. It’s where many Vim users get a lot of pleasure from coding and writing. It felt liberating, moving my cursor with the precision of a surgeon.</p>
<p>Although speed is a smaller benefit, it got me started when I saw <a target="_blank" href="https://youtu.be/1UXHsCT18wE">others</a> navigating in Vim. After climbing the steep learning curve, it’s still one of the most powerful skills I've ever learned in my career, working for a living on a computer.</p>
<p>Let’s debunk the myth of Vim and learn how it’s possible to remember all the shortcuts using the specific Vim language. We'll see how to move with vim motions, and I'll share what I’ve learned so far, and why you might give Vim a try as well.</p>
<h2 id="heading-learning-the-vim-language">Learning the Vim Language</h2>
<p>Lots of things have been said about Vim – how fast it is, how only Linux nerds use it, and that it’s impossible to <a target="_blank" href="https://stackoverflow.com/q/11828270">exit Vim</a>.</p>
<p>For myself, I fell in love with the “Vim language”. You see, I’m bad at remembering anything and thought that Vim was not for me. But this wasn't the case for one specific reason: Vim <em>motions</em> and its language.</p>
<p>I learned that there’s a grammar behind the editor. With it, you express what you want to do first, how many times, and then what you want it to apply.</p>
<p>Let’s get deeper into Vim and the language behind it.</p>
<h3 id="heading-how-the-vim-language-and-motions-work">How the Vim Language and Motions Work</h3>
<p>Vim has a terrific language or grammar behind its shortcuts. Instead of remembering a thousand shortcuts, you can learn a couple and combine them.</p>
<p>These are often called the Vim language or Vim motions for moving around. This has nothing to do with the editor yet – these are universal and available in other editors as well.</p>
<p>For example, there's <a target="_blank" href="https://marketplace.visualstudio.com/items?itemName=JaredParMSFT.VsVim">VSVim</a> for VSCode, <a target="_blank" href="https://plugins.jetbrains.com/plugin/164-ideavim">IdeaVim</a> for the JetBrains products, <a target="_blank" href="https://www.sublimetext.com/docs/vintage.html">Vintage Mode</a> for Sublime, and so on. But there are also Browser extensions like <a target="_blank" href="https://chrome.google.com/webstore/detail/vimium/dbepggeogbaibhgnhhndojpepiihcmeb?hl=en">Vimium</a> or <a target="_blank" href="https://chrome.google.com/webstore/detail/firenvim/egpjdkipkomnmjhjmdamaniclmdlobbo?hl=en">Firenvim</a>, and Gmail even adapted some of Vim's <a target="_blank" href="https://support.google.com/mail/answer/6594?hl=en&amp;co=GENIE.Platform%3DDesktop#zippy=%2Cjumping%2Cnavigation">shortcuts</a> for navigation (<code>j</code>, <code>k</code> for moving, <code>g</code> for jumping).</p>
<p>Everyone who types on a computer eight hours a day should learn the Vim language. Yes, it’s hard in the beginning, but that’s the case with everything new and different. But getting better every day and having more fun coding or writing should be motivation enough. You're not too busy to learn - you'll learn as you go.</p>
<p><img src="https://www.sspaeti.com/blog/why-using-neovim-data-engineer-and-writer-2023/weel-too-busy.png" alt="Are you too busy to improve | Image from Steen Schledermann’s blog: https://steenschledermann.wordpress.com/ " width="600" height="400" loading="lazy"></p>
<h4 id="heading-vim-grammar">Vim Grammar</h4>
<p>Just as spoken language <strong>grammar</strong> has verbs, subjects, and objects, so does the Vim language. The grammar has different <strong>verbs</strong> to begin with. Copying (or yanking) in Vim with <code>y</code>, deleting with <code>d</code>, pasting with <code>p</code>, changing with <code>c</code>, and so on.</p>
<p>For example, the easiest shortcut is copying a line with <code>yy</code>. In this case, yank is the verb and the second <code>y</code> is a synonym for <code>y_</code>. The <code>y</code> is doubled up which makes it easier to type since it's a joint operation.</p>
<p>Next, we can add movements. Each verb takes a <strong>subject</strong> for their movements. There are lots of movements (more in the next section) – the easiest is with numbers.</p>
<p>For example, to copy three lines, you add a 3 in front, such as <code>3yy</code>. You can do that with all verbs, like deleting three lines is <code>3dd</code>. Another would be <code>{</code> and <code>}</code> to move to the beginning or end of the paragraph, respectively.</p>
<p>In addition to verbs and subjects, the Vim language also has <strong>objects</strong>. For example, we can save text into different clipboards (called a register in Vim) with <code>"ay</code>. Here, we copy it into register a, which would be the object. We can paste it again by doing the same but using the verb paste instead of yank <code>"ap</code>.</p>
<p>There are even <strong>adjectives</strong> and <strong>adverbs</strong> with prefixes. Usually, you use a verb and an object. But instead of going down three lines with <code>3J</code>, which joins the following three lines, you could add <code>d5}</code>, which means “delete from the current line through the end of the fifth paragraph down from here.”</p>
<p>For me, the most magical thing about Vim is how you navigate and edit text – and it still has nothing to do with the editor.</p>
<p>Sure Vim was the one that introduced and perfected these actions, but again – you can get them anywhere else. This goes deep into the Vim language, yet we still need to touch on the editor. This is important to know.</p>
<p>I hope you've started seeing the power of such patterns, though. With a couple of verbs and objects, you can already know hundreds of combinations without memorizing each one individually.</p>
<p>You can watch a video on <a target="_blank" href="https://youtu.be/wlR5gYd6um0">Mastering the Vim Language</a> or read a full exposition of the Vim language on this terrific <a target="_blank" href="https://stackoverflow.com/a/1220118">StackOverflow</a> comment.</p>
<h3 id="heading-vim-motions">Vim Motions</h3>
<p>Vim motions are how you navigate, whether you navigate to the end of the word or back to the start of the document – these are all motions.</p>
<p>These are the first things you start learning (and hating) when learning Vim. They're extra hard to figure out initially, but they're something you'll want to use everywhere when you get used to them.</p>
<p>Instead of using arrow keys, Vim uses <code>jk</code> to move down and up and <code>hl</code> to move left and right. The main idea is to use the keys your right hand naturally rests on. You do not need to move your hands or even fingers for navigation.</p>
<p>Again, this seems like a small thing, but once you've learned it, you know why everyone is telling you about it.</p>
<p>Some common motions are:</p>
<pre><code class="lang-python">h,j,k,l - left, down, up, right
w,W - to start of next word <span class="hljs-keyword">or</span> WORD
b,B - to start of previous word <span class="hljs-keyword">or</span> WORD
e,E - to end of word <span class="hljs-keyword">or</span> WORD
$   - to end of line
^   - to start of line
</code></pre>
<p>You can find the most important motions to start with in this cheatsheet:</p>
<p><img src="https://www.sspaeti.com/blog/why-using-neovim-data-engineer-and-writer-2023/vim-language-cheetsheet.png" alt="Vim Command Cheat Sheet from Cloud Guru" width="600" height="400" loading="lazy"></p>
<p>This Vim Command Cheat Sheet is from <a target="_blank" href="https://www.pluralsight.com/resources/blog/cloud/a-vim-cheat-sheet-reference-guide">Cloud Guru</a>.</p>
<h2 id="heading-how-to-use-vim-modes-normal-insert-visual-and-command">How to Use Vim Modes (normal, insert, visual, and command)</h2>
<p>Modes are another thing that might get you confused at the beginning.</p>
<p>When you launch Vim, you are not typing what you click on your keyboard as you are not in the “insert” mode that you're likely familiar with from other editors. Instead, the normal mode you are in lets you do the commands explained in the above Vim language and motions.</p>
<p>Vim is the only editor that <strong>optimizes editing text</strong> instead of writing from a blank page.</p>
<p><img src="https://www.sspaeti.com/blog/why-using-neovim-data-engineer-and-writer-2023/vim-modes.png" alt="Three modes illustrated (escape mode being the command mode) | Image from Geekforgeeks https://www.geeksforgeeks.org/vi-editor-unix/" width="600" height="400" loading="lazy"></p>
<p>That’s another reason Vim makes you so efficient: you have different modes for each phase of your current work or task.</p>
<ul>
<li><p>Normal mode is for reading code and navigating quickly.</p>
</li>
<li><p>Insert mode is for when you want to add some code or text.</p>
</li>
<li><p>Visual mode is unique, the same as highlighting text with the mouse, but with the above Vim motions.</p>
</li>
<li><p>And command mode is the powerhouse, where you can type Linux commands such as formatting a JSON file with <code>:%!jq</code> (whereas <a target="_blank" href="https://stedolan.github.io/jq/">jq</a> is a command line tool installed on your machine) and execute them within Vim. This is also where you can use Vim commands such as <code>:sort</code> for sorting your files.</p>
</li>
</ul>
<p>I could go on here, but I want to dive into the editor itself now and explore why I learned it initially and how to get started.</p>
<h2 id="heading-introduction-to-vim-the-editor-neovim-lunarvim-and-helix">Introduction to Vim the Editor (Neovim, Lunarvim, and Helix)</h2>
<p>So what is Vim the editor, then? It started with the simple vi editor, a basic editor that implements the Vim language and can edit text. It's a little like Notepad++, which you might use on Windows, but without a mouse and context menu.</p>
<p>Vim is simply an improved version of Vi with more features.</p>
<p><img src="https://www.sspaeti.com/blog/why-using-neovim-data-engineer-and-writer-2023/vi-vs-vim.png" alt="Differences between Vi and Vim | Image by Linuxiac: https://linuxiac.com/differences-between-vi-and-vim-text-editors-explained/" width="600" height="400" loading="lazy"></p>
<p>Today there is even a newer version of Vim called <a target="_blank" href="https://neovim.io/">Neovim</a>. This version is super popular, and I’ve started using Neovim as well. Compared to Vim, Neovim uses <a target="_blank" href="https://www.lua.org/">Lua</a>, an actual programming language, to configure and extend the editor. This makes writing plugins and configuring Neovim easier compared to Vim's native <a target="_blank" href="https://learnvimscriptthehardway.stevelosh.com/">Vimscript</a>.</p>
<p>Neovim is a great place to start learning Vim today, as it has so many awesome <a target="_blank" href="https://github.com/rockerBOO/awesome-neovim">plugins</a>. Neovim also won the most <a target="_blank" href="https://survey.stackoverflow.co/2022/#integrated-development-environment">loved IDE</a> on the StackOverflow survey a couple of times, last in 2022.</p>
<p>There is also an editor called <a target="_blank" href="https://github.com/helix-editor/helix">Helix</a> built in Rust, but it has minor deviations from the Vim language, which make it a less optimal place to start.</p>
<p>If you want to get started without needing to know anything about Neovim and spending hours on configurations, you can begin with <a target="_blank" href="https://www.lunarvim.org/">LunarVim</a>. It's a distro with all the features you know from VS Code already included.</p>
<p>Suppose you are comfortable with the terminal and realize you want to change the editor to your liking. In that case, you can kickstart your journey with a <a target="_blank" href="https://github.com/nvim-lua/kickstart.nvim">simple single-file configuration</a> with many explanations that will work out of the box. You can also learn each config by opening the single config file.</p>
<h2 id="heading-why-i-learned-vim">Why I Learned Vim</h2>
<p>Using the standard input method we use in our editors daily, we will eventually stagnate at a certain level. Sure, you can use <code>cmd+arrow-keys</code> (on a Mac) to jump to the beginning of a line or <code>option+arrow-keys</code> to jump between words instead of characters.</p>
<p>But what happens once you've mastered that? What if you need to change something in the middle of a sentence? There is no other way to jump several times with this option, or you move your hands away each time to reach the mouse to click on the exact spot.</p>
<p>One day, I saw a coworker work in Vim, and everything clicked. The Vim language and motions were the things I needed all along. So I installed the VS Code plugin, watched a couple of YouTube videos, and started my journey to learn the basic movements.</p>
<p>I also love learning new things and, even better, I'm always looking for ways to make me more productive 😉.</p>
<p>But as many of you might have experienced, the hardest part of learning Vim is getting started. The initial learning curve is very steep. Below is an illustration that shows this :).</p>
<p><img src="https://www.sspaeti.com/blog/why-using-neovim-data-engineer-and-writer-2023/vim-learning-curve.png" alt="The learning curve for text editors. Although funny, very accurate | Image from Why I Love Using Vim To Write Code: https://youtu.be/o4X8GU7CCSU" width="600" height="400" loading="lazy"></p>
<p>It took me also two or three times trying to start learning Vim until I fully grasped it. I switched back and forth. As well as having to get work done, it is sometimes hard to switch entirely from one day to another. But I just loved learning all the movements, and I knew it would make me faster after a short time.</p>
<h2 id="heading-why-i-love-vim">Why I Love Vim</h2>
<p>I have been using Vim for only eight months, and coding with Python for around six years. I've been using other code editors since my career started in 2003. Each editor I used had its strengths and its appeal. But I never experienced such efficiency gains as I have with Vim.</p>
<p>In the end, use the editor that works best for you. Personally, I want my editor to help me work as fast as possible, especially since I use it daily. Investing a bunch of time learning Vim is necessary, but it pays off over time. That’s the whole point with Vim and especially the Vim language.</p>
<p>An underrated skill in general among programmers is using the <strong>terminal</strong>. By learning your editor, especially with Vim, you will naturally learn more about the terminal and improve your Linux skills (reverse search, lazy git, Tmux, and many more).</p>
<p>Before Vim, I only used the terminal if I had to. I googled everything, and today, I use the terminal with its helpful manuals whenever I can.</p>
<p>Sometimes I’m surprised by myself as well, and it’s super nerdy – but it’s so effective. I’ve become a much better developer since starting to get comfortable with Vim.</p>
<p>Tweaking and optimizing Vim can take hours and days, and it's unavoidable in the beginning. But after a while, your <a target="_blank" href="https://github.com/sspaeti/dotfiles">dotfiles</a> mature, and you start changing things less. You will also get much faster at trying out a new plugin or adding a remap.</p>
<p>Also, Vim is <strong>fun</strong>! Working in Neovim is one of the highlights of my everyday work. Improving your text editor and making it your own – maybe in ways no one else has optimized – is awesome.</p>
<p>For example, I write a lot, so I optimized for writing markdown and programming in Python. That’s what adds a lot to my happiness as a coder.</p>
<p>Because of all this, <a target="_blank" href="https://github.com/tjdevries">TJ DeVries</a> calls Neovim a <a target="_blank" href="https://brain.sspaeti.com/pde-personalized-development-environment">PDE</a> (Personalized Development Environment), not “just” an IDE. You can learn more about this in <a target="_blank" href="https://www.youtube.com/c/ThePrimeagen">ThePrimeagen</a>’s truly inspiring <a target="_blank" href="https://youtube.com/playlist?list=PLm323Lc7iSW_wuxqmKx_xxNtJC_hJbQ7R">Vim videos</a> and learn why he used <a target="_blank" href="https://youtu.be/D4YTJ2W5q4Y">Vim in 2022</a>.</p>
<p>Vim also manifested <strong>minimalism</strong> more in me. I used the terminal instead of fancy GUIs and plain text files for clarity, freedom, blazingly fast shortcuts, no vendor lock-in, and staying in the <a target="_blank" href="https://brain.sspaeti.com/deep-work">Flow</a> with the content in front.</p>
<p>Vim changed not only my workflow but how I was able to <strong>edit at the speed of thought</strong>. Instead of thinking, “I want to edit that word”, my fingers jump to that word and change it with a few keystrokes.</p>
<h2 id="heading-vim-for-data-engineering">Vim for Data Engineering</h2>
<p>My data engineering workflow uses Neovim with the <a target="_blank" href="https://microsoft.github.io/language-server-protocol/">LSP</a> (Language Server Protocol) <a target="_blank" href="https://github.com/microsoft/pyright">pyright</a> installed with <a target="_blank" href="https://github.com/williamboman/mason.nvim">mason</a>. There's much more with <a target="_blank" href="https://github.com/sspaeti/dotfiles/tree/master/tmux">Tmux</a>, but you can find all the details on <a target="_blank" href="https://github.com/sspaeti/dotfiles/tree/master/nvim">dotfiles/nvim</a>.</p>
<p><img src="https://www.sspaeti.com/blog/why-using-neovim-data-engineer-and-writer-2023/vim-mason-install.png" alt="Installing Pyright with Mason" width="600" height="400" loading="lazy"></p>
<h2 id="heading-vim-for-writing">Vim for Writing</h2>
<p>I’m still using <a target="_blank" href="https://brain.sspaeti.com/obsidian">Obsidian</a> a lot more for writing (see more on my <a target="_blank" href="https://sspaeti.com/blog/pkm-workflow-for-a-deeper-life/">PKM workflow</a>) due to its additional features of supported images, backlinks, graphs, and plugins specified for note-taking, such as <a target="_blank" href="https://brain.sspaeti.com/readwise">ReadWise</a> (syncing my highlight from books, and tweets), <a target="_blank" href="https://github.com/blacksmithgu/obsidian-dataview">Dataview</a> (using notes as a database), <a target="_blank" href="https://excalidraw.com/">Excalidraw</a> (drawing with Markdown format), Templates, and so on.</p>
<p>Nevertheless, I write more and more in Neovim. For now, I use <a target="_blank" href="https://github.com/folke/zen-mode.nvim">ZenMode</a> (for centering the text), Grammarly (for linting grammar), <a target="_blank" href="https://github.com/btford/write-good">write-good</a> (linting grammar), and specifically <a target="_blank" href="https://github.com/epwalsh/obsidian.nvim">Obsidian.nvim</a> (follow backlinks, and so on.). You find all details in my <a target="_blank" href="https://github.com/sspaeti/dotfiles">dotfiles</a>.</p>
<p>In Obsidian, I use the <a target="_blank" href="https://publish.obsidian.md/hub/04+-+Guides%2C+Workflows%2C+%26+Courses/for+Vim+users">Vim mode</a> Obsidian <a target="_blank" href="https://github.com/sspaeti/dotfiles/blob/master/obsidian/.vimrc">.vimrc</a> and map most <a target="_blank" href="https://github.com/sspaeti/dotfiles/tree/master/obsidian">hotkeys</a> to my Vim settings. At the same time, I've been writing more and more in Neovim and have been progressively moving over to full Neovim.</p>
<p>Plugins such as <a target="_blank" href="https://github.com/nvim-telescope/telescope.nvim">Telescope</a> and simple grep features that I use for coding work very well with Markdown. Here are some clips showing what is possible in an excellent talk about <a target="_blank" href="https://youtu.be/2ORWaIqyj7k">Writing, Editing, and World-Building at the speed of thought with Vim</a>.</p>
<h2 id="heading-why-you-should-learn-vim-too">Why You Should Learn Vim, Too</h2>
<p>When I heard about Vim, I thought that it was only for software engineers and Linux nerds 😅. I never thought I was going to use it as well. But how did I get into it?</p>
<p>I've already shared some reasons why I love Vim. But it really changed all my workflows, not only as a developer but also how I surf the internet, write, navigate, and use tools. I search for a Vim mode in any application I use.</p>
<p>But if you don't enjoy fiddling and optimizing your workflow, and if you don't write or code for a living, Vim might not be for you. Start with your current editor and activate the Vim mode before you do anything with Vim. It will save you <a target="_blank" href="https://stackoverflow.blog/2017/05/23/stack-overflow-helping-one-million-developers-exit-vim/">a lot of frustration</a>, trust me 😅.</p>
<h2 id="heading-how-to-get-started-using-vim">How to Get Started Using Vim</h2>
<p>There are many good resources that'll help you get started with Vim. The easiest is to type <code>vimtutor</code> into your terminal, which is an interactive tutorial for Vim.</p>
<p>I've already linked a few YouTube videos above – especially check out ThePrimagen starting with <a target="_blank" href="https://youtu.be/X6AR2RMB5tE">Vim As Your Editor</a> or <a target="_blank" href="https://youtu.be/84qoMxS-iqQ">Why even bother with Vim or Neovim in 2022</a>.</p>
<p>I started with Ben Awads’s <a target="_blank" href="https://youtu.be/IiwGbcd8S7I">Vim tutorial</a> back then. An excellent <a target="_blank" href="https://youtu.be/a6Q8Na575qc">Lecture: Editors (Vim) (2020)</a>. <a target="_blank" href="https://youtu.be/wlR5gYd6um0">Mastering the Vim Language</a>. I also collect a small <a target="_blank" href="https://www.youtube.com/playlist?list=PLxGd5Sk9B7IZfFOxGWgg8XswEKZ6lEzmh">playlist</a> on YouTube with Vim content. A big inspiration also <a target="_blank" href="https://youtu.be/sSOfr2MtRU8">dev workflow using Tmux and Vim</a> from <a target="_blank" href="https://twitter.com/inkdrop_app?lang=en">Takuya</a>.</p>
<h2 id="heading-wrapping-up">Wrapping Up</h2>
<p>We have learned that Vim is a powerful text editor popular among developers. It's based on shortcuts, called the Vim language, which can make coding and writing faster and more efficient.</p>
<p>With Vim, you can jump to any specific text position and rapidly make precise edits. While learning Vim can be challenging, it is well worth the effort in the long run as it will improve your productivity and bring joy to your coding experience.</p>
<p>If you want to go further, try <a target="_blank" href="https://github.com/tmux/tmux/wiki">Tmux</a>, which plays well with Vim. You could even go one level deeper, which is a dedicated keyboard layout such as <a target="_blank" href="https://en.wikipedia.org/wiki/Dvorak_keyboard_layout">Dvorak</a> or <a target="_blank" href="https://brain.sspaeti.com/halmak">Halmak</a> (which I started learning at some point). Or buy a fancy <a target="_blank" href="https://www.reddit.com/r/kinesisadvantage/comments/yplirr/im_also_part_of_the_team_kinesis_now/?utm_source=share&amp;utm_medium=web2x&amp;context=3">ergonomic keyboard</a> or <a target="_blank" href="https://bit.ly/sspaeti_keyboard">build one yourself</a>.</p>
<p>Thanks for reading this far. I hope you enjoyed this article. I'm looking forward to hearing your comments and experiences.</p>
<p><em>You can read more of my other tutorials at</em> <a target="_blank" href="https://www.sspaeti.com/blog/why-using-neovim-data-engineer-and-writer-2023/"><em>www.sspaeti.com</em></a><em>.</em></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Use Vim – Tutorial for Beginners ]]>
                </title>
                <description>
                    <![CDATA[ Vim is one of the most popular text editors among Linux users. Linux System Administrators especially often prefer it to other editors.  In this article, you'll learn a lot about Vim and see how you can quickly start using Vim as a developer. What is... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/vim-beginners-guide/</link>
                <guid isPermaLink="false">66ba10fc439ed06e055759fc</guid>
                
                    <category>
                        <![CDATA[ beginner ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Linux ]]>
                    </category>
                
                    <category>
                        <![CDATA[ vim ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Arunachalam B ]]>
                </dc:creator>
                <pubDate>Mon, 30 Jan 2023 16:08:32 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/01/BB---Vim---A-Quick-Beginner-s-Guide.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Vim is one of the most popular text editors among Linux users. Linux System Administrators especially often prefer it to other editors. </p>
<p>In this article, you'll learn a lot about Vim and see how you can quickly start using Vim as a developer.</p>
<h2 id="heading-what-is-vim">What is Vim?</h2>
<p>Vim is an acronym for <strong>Vi IM</strong>proved. It is a free and open-source cross-platform text editor. It was first released by Bram Moolenaar in 1991 for UNIX variants. </p>
<p>Vim is based on the original Vi editor, which was created by Bill Joy in 1976. In the 90’s, it started becoming clear that Vi was lacking in some features when compared with the Emacs editor. So Bram implemented many missing features and released it under the name Vim. </p>
<h2 id="heading-how-to-install-vim">How to Install Vim</h2>
<p>Vim runs across various platforms such as Windows, Linux, and Mac. </p>
<p>To install Vim on Windows, download the executable file from the <a target="_blank" href="https://www.vim.org/download.php">Vim site</a> and run the file. Follow the instructions shown on the screen and you'll be good to go. </p>
<p>Vim comes pre-installed on most *nix operating systems. But if it's not installed on your system, you can install it with a package manager of your choice. </p>
<p>Here's the installation command for Debian-based operating systems:</p>
<pre><code class="lang-bash">sudo apt-get update
sudo apt-get install vim
</code></pre>
<p>To ensure that it's installed properly, run <code>which vim</code> and you should get <code>/usr/bin/vim</code> in your output. </p>
<h2 id="heading-how-to-get-started-with-vim">How to Get Started with Vim</h2>
<p>You can get started with Vim by typing its name on the terminal like this:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-274.png" alt="Image" width="600" height="400" loading="lazy">
<em>Start Vim</em></p>
<p>Once you enter the above command, you'll be able to see a screen displaying info about Vim and some instruction to find help and exit Vim. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-276.png" alt="Image" width="600" height="400" loading="lazy">
<em>Vim Introduction</em></p>
<h2 id="heading-vim-modes">Vim Modes</h2>
<p>You should be aware of the most important concept in Vim before moving on: modes in Vim. </p>
<p>Everything in Vim is considered a mode. You can achieve whatever you want if you understand modes in Vim. There are many modes in Vim. But, we'll be looking at the 4 most important modes. </p>
<p>They are:</p>
<ol>
<li>Command Mode</li>
<li>Command-Line Mode</li>
<li>Insert Mode</li>
<li>Visual Mode</li>
</ol>
<p>Let's explore them one by one. </p>
<h3 id="heading-what-is-command-mode">What is Command Mode?</h3>
<p>This is the default mode (also called Normal mode) in Vim. Whenever Vim starts, you'll be in this mode. You can switch to any mode from this mode. You can't do this in any other modes. </p>
<p>Basically, to switch from one mode to another, you have to come to Command Mode first and then navigate to the other mode. The commands that you run without any prefix (colon) indicate that you're running the command in command mode. </p>
<h3 id="heading-what-is-insert-mode">What is Insert Mode?</h3>
<p>This mode is used to edit the contents of the file. You can switch to insert mode by pressing <code>i</code> from command mode. You can use the <code>Esc</code> key to switch back to command mode. </p>
<h3 id="heading-what-is-command-line-mode">What is Command Line Mode?</h3>
<p>You can use this mode to play around with some commands. But the commands in this mode are prefixed with a colon (:). You can switch to this mode by pressing : (colon) in command mode. </p>
<h3 id="heading-what-is-visual-mode">What is Visual Mode?</h3>
<p>You use this mode to visually select some text and run commands over that section of code. You can switch to this mode by pressing <code>v</code> from the command mode. </p>
<p>The above 4 modes are enough to perform a basic set of file operations in Vim.</p>
<p>Ok the theory is done. Let's explore Vim practically.</p>
<h2 id="heading-common-text-editor-operations-in-vim">Common Text Editor Operations in Vim</h2>
<h3 id="heading-how-to-create-a-new-file">How to Create a New File</h3>
<p>Creating a new file with Vim is simple. You can do it from command line mode. </p>
<p>Run the following command to create a new file:</p>
<pre><code class="lang-vim">:edit sample.txt
</code></pre>
<p>The above command opens a <code>sample.txt</code> file in edit mode if it exists, and creates a new file otherwise. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-278.png" alt="Image" width="600" height="400" loading="lazy">
<em>Create a new file with the name <code>sample.txt</code></em></p>
<p>After running that command, you'll be in command mode (as shown in the below screenshot), and you'll not be able to enter any text:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-279.png" alt="Image" width="600" height="400" loading="lazy">
<em>Command mode showing new file created</em></p>
<p>To add some text to the created file, press <code>i</code> in the keyboard. You use the <code>i</code> command to enter some text in the file. Once you press <code>i</code>, you'll be able to see that you entered Insert mode in Vim by looking at the bottom left of the file. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-280.png" alt="Image" width="600" height="400" loading="lazy">
<em>Insert mode in <code>sample.txt</code> file in Vim</em></p>
<p>In this mode, you can type whatever you want into the file. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-281.png" alt="Image" width="600" height="400" loading="lazy">
<em>Added some content in <code>sample.txt</code> file</em></p>
<p>We're done with writing our content. And now we'll want to save the file. If you do not save and just close the terminal at this point, all your content will be lost. </p>
<h3 id="heading-how-to-save-a-file">How to Save a File</h3>
<p>To save a file, you have to switch from Insert mode to Command Line mode. Remember I told you earlier – whenever you want to switch from one mode to another, you have to first switch to Command mode and then you can easily switch to whatever mode you want. </p>
<p>To switch to Command mode from Insert mode, you have to press the <code>Esc</code> key. </p>
<p>After you press the <code>Esc</code> key, you'll not be able to see the  <code>--INSERT--</code>  at the bottom left. This indicates that you're not in Insert mode anymore and you're now in Command mode. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-283.png" alt="Image" width="600" height="400" loading="lazy">
<em>Command mode in <code>sample.txt</code> file</em></p>
<p>To save the file, type the following command:</p>
<pre><code class="lang-vim">:w
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-284.png" alt="Image" width="600" height="400" loading="lazy">
<em>Command to save the file</em></p>
<h3 id="heading-how-to-close-a-file-and-exit-vim">How to Close a File and Exit Vim</h3>
<p>Once you save the file, you can close Vim by closing the terminal. But, the proper way to close the file and the Vim editor is by using the following command:</p>
<pre><code class="lang-vim">:q
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-285.png" alt="Image" width="600" height="400" loading="lazy">
<em>Close the file and vim editor</em></p>
<p>The above command closes the file and quits the vim editor. </p>
<p>Alternatively, you can use a command that's the combination of the above 2 commands (save &amp; quit) to quickly save and quit Vim. The command is:</p>
<pre><code class="lang-vim">:wq
</code></pre>
<p>The above command quits the Vim editor immediately after saving the file. </p>
<h3 id="heading-how-to-edit-a-file-in-vim">How to Edit a File in Vim</h3>
<p>To edit a file, you have to open the file using Vim and switch to Insert mode. </p>
<p>Let's open the <code>sample.txt</code> file we created above:</p>
<pre><code class="lang-vim">vim sample.txt
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-287.png" alt="Image" width="600" height="400" loading="lazy">
<em>Open <code>sample.txt</code> file using Vim</em></p>
<p>We are in Command mode now. To edit the file, we have to switch to Insert mode. As we saw earlier, pressing <code>i</code> from the Command mode will switch to Insert mode. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-289.png" alt="Image" width="600" height="400" loading="lazy">
<em>Switch to Insert mode by pressing <code>i</code></em></p>
<p>Follow the same procedure for saving the file and quitting Vim. Press <code>Esc</code> on the keyboard and type <code>:w</code> to save the file and <code>:q</code> to quit Vim. </p>
<p>You may wonder, though, what if I want to close the file without saving my changes? (Ignore the changes I made and bring the file back to the old state). </p>
<h4 id="heading-how-to-close-the-file-without-saving-the-changes">How to close the file without saving the changes</h4>
<p>To close the file without saving the changes, you have to run <code>:q!</code> from Command mode. </p>
<p>Let's explore this with an example:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-292.png" alt="Image" width="600" height="400" loading="lazy">
<em>Content in <code>sample.txt</code> file</em></p>
<p>I've added some more content to the file. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-293.png" alt="Image" width="600" height="400" loading="lazy">
<em>Added some content in <code>sample.txt</code> file</em></p>
<p>But, I don't want to save the changes I made now. To close the file without saving this change, we have to switch to Command mode (by pressing the <code>Esc</code> key). Type <code>:q!</code> in the Command mode. This will close the file ignoring the changes made. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-294.png" alt="Image" width="600" height="400" loading="lazy">
<em>Ignore saving the <code>sample.txt</code> file</em></p>
<p>Let's view the file and confirm if we get the expected output:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-295.png" alt="Image" width="600" height="400" loading="lazy">
<em>View <code>sample.txt</code> file</em></p>
<p>Yeah. The file does not have the last line which we added recently. So, the changes were not saved. </p>
<h3 id="heading-how-to-cut-copy-and-paste-text-from-a-file-using-vim">How to Cut, Copy, and Paste Text from a File using Vim</h3>
<p>You can Cut, Copy, and Paste in 2 ways in Vim. They are:</p>
<ol>
<li>Using Visual mode</li>
<li>Using keyboard</li>
</ol>
<p>Out of these two ways, Visual mode is simpler to understand. Since this is a beginner-friendly guide, let's explore how to cut, copy, and paste in Visual mode. </p>
<p>Let's open the file in command mode before we proceed:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-231.png" alt="Image" width="600" height="400" loading="lazy">
<em><code>sample.txt</code> file opened in command mode in Vim</em></p>
<p>Let's assume you want to copy the word "Hello" from the 1st line and paste it into the 3rd line. </p>
<p>The first step is to place your cursor in the place from where you want to copy the text (being in command mode).</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-232.png" alt="Image" width="600" height="400" loading="lazy">
<em>Moved the cursor to the beginning of the word <code>Hello</code></em></p>
<p>Enter Visual mode by pressing the <code>v</code> key on the keyboard. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-233.png" alt="Image" width="600" height="400" loading="lazy">
<em>Enter Visual mode</em></p>
<p>The  <code>-- VISUAL –-</code>  text at the bottom left indicates that we're in visual mode. </p>
<p>Move the cursor to the place where the text you want to copy ends. </p>
<p>In this case, I'm moving the cursor to the letter <code>o</code> of the word <code>Hello</code>. </p>
<p>While you move your cursor, Visual mode highlights the text from the beginning up to your cursor.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-235.png" alt="Image" width="600" height="400" loading="lazy">
<em>Highlighted text in Visual mode</em></p>
<p>Once you're done moving your cursor to the right place, hit <code>y</code> to copy the text or hit <code>d</code> to cut the text. </p>
<p>In this case, I'm copying the text. So, I press <code>y</code> on my keyboard. </p>
<p>Move the cursor to the place where you want to paste the text. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-296.png" alt="Image" width="600" height="400" loading="lazy">
<em>Move the cursor to the place where you want to paste the text</em></p>
<p>In our case, we have to move the cursor to the 3rd line. </p>
<p>Press <code>p</code> (in lowercase) to paste the text after the cursor and <code>P</code> (in uppercase) to paste the text before the cursor. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-236.png" alt="Image" width="600" height="400" loading="lazy">
<em><code>Hello</code> text pasted on 3rd line</em></p>
<p>Press <code>:wq</code> to save and close the file</p>
<h3 id="heading-how-to-find-and-replace-text-in-vim">How to Find and Replace Text in Vim</h3>
<p>Finding text and replacing it with some other text is simple and straightforward in Vim. There's a one-line command that simplifies this entire process. </p>
<p>Here's the syntax:</p>
<pre><code class="lang-vim">:[range]s/{pattern}/{string}/[flags]
</code></pre>
<p>Let's dismantle each part and understand how it all works. </p>
<ul>
<li><code>[range]</code> indicates that you can pass the range of lines. Pass % to find and replace in all lines. The range is separated by a comma. To find and replace between lines 5 to 10, pass 5,10. Use <code>.</code> to represent the current line and <code>$</code> the last line of the file. </li>
<li><code>{pattern}</code> indicates the pattern to find the text. You can pass regex patterns here.</li>
<li><code>{string}</code> is the string to replace in the found text.  </li>
<li><code>[flags]</code> indicates if you wish to pass any additional flags (for example, the flag <code>c</code> is passed to confirm before replacing the text). By default, this does a case-sensitive search. You can change it to do a case-insensitive search by passing a <code>i</code> flag. </li>
</ul>
<p>Alright, let's explore this with an example. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-237.png" alt="Image" width="600" height="400" loading="lazy">
<em><code>sample.txt</code> file content</em></p>
<p>Our <code>sample.txt</code> file has 2 "Hello"s. Let's replace "Hello" with "Hi" at both places. </p>
<p>The command to do that is:</p>
<pre><code class="lang-vim">:%s/Hello/Hi/g
</code></pre>
<ul>
<li><code>%s</code> indicates replacing the content in the entire file</li>
<li><code>Hello</code> is the search text</li>
<li><code>Hi</code> is the text to replace</li>
<li><code>g</code> indicates making the change globally</li>
</ul>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-238.png" alt="Image" width="600" height="400" loading="lazy">
<em>While running the command to change "Hello" with "Hi"</em></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-239.png" alt="Image" width="600" height="400" loading="lazy">
<em>After running the command</em></p>
<p>Let's understand this with another example. </p>
<p>This time, I want to change the word "Hi" (case-insensitive search) that occurs between lines 2 and 3 and replace it with "Hello and Welcome", with a confirmation to change each occurrence. </p>
<p>The command to do that is:</p>
<pre><code class="lang-vim">:2,3s/Hi/Hello and Welcome/gci
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-297.png" alt="Image" width="600" height="400" loading="lazy">
<em>Running the command to change the text from line 2 to line 3</em></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-241.png" alt="Image" width="600" height="400" loading="lazy">
<em>Asking for confirmation to change the occurrence</em></p>
<p>Here's a description for each option:</p>
<ul>
<li><code>y</code> - Replace the match </li>
<li><code>n</code> - Skip the match</li>
<li><code>a</code> - Substitutes the match and all remaining occurrences of the match</li>
<li><code>q</code> or <code>Esc</code> - Quit substitution</li>
<li><code>l</code> - Replace the match and quit</li>
<li><code>CTRL+Y</code> - Scroll the screen down</li>
<li><code>CTRL+E</code> - Scroll the screen up</li>
</ul>
<p>I want to accept the change. So, I press <code>y</code>. Here's the output after pressing <code>y</code>. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-242.png" alt="Image" width="600" height="400" loading="lazy">
<em>After replacing the word</em></p>
<p>Since we have only one occurrence of "Hi" between lines 2 and 3, it did not ask for any further confirmation and the operation is complete. </p>
<h3 id="heading-how-to-undo-or-redo-in-vim">How to Undo or Redo in Vim</h3>
<p>To undo a change in Vim, press <code>u</code> in command mode. To redo, press <code>CTRL + R</code>. You can prepend a number (n) with <code>u</code> to undo <code>n</code> times. for example, <code>2u</code> will undo 2 times. To list the available undo options, type <code>:undolist</code> in command mode. </p>
<p>Let's understand this with an example. </p>
<p>Here's the current state of our sample.txt file:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-254.png" alt="Image" width="600" height="400" loading="lazy">
<em>Current state of <code>sample.txt</code> file</em></p>
<p>I have my cursor at "a" in the "Hello and Welcome" text on 3rd line. Let's remove the word "and" by typing <code>dw</code> on command mode:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-257.png" alt="Image" width="600" height="400" loading="lazy">
<em>Removed the word <code>and</code> by typing <code>dw</code> in command mode</em></p>
<p>Let's undo to bring the word "and" back into the file. To do so, press <code>u</code> in command mode. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-258.png" alt="Image" width="600" height="400" loading="lazy">
<em>Changes are undone after typing <code>u</code> in command mode</em></p>
<p>Let's redo and take away the word "and" by typing <code>CTRL + R</code> in command mode. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-298.png" alt="Image" width="600" height="400" loading="lazy">
<em>Changes were applied again on redo by pressing <code>CTRL + R</code> in command mode</em></p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>In this article, you have learned the basics of Vim. This article should be enough to get you going and do some basic file read/write operations with Vim. </p>
<p>Just keep in mind that I've not even covered 1% of Vim. But I'm sure these basics will help you explore Vim quickly and confidently. </p>
<p>To learn more about Vim, subscribe to my email newsletter at my <a target="_blank" href="https://www.freecodecamp.org/news/p/e557f026-0774-4fad-9c2f-d598e88b5250/5minslearn.gogosoon.com/?ref=fcc_vim_a_quick_getting_started_guide">site</a> and follow me on social media. </p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Linux `Vimdiff` Command – How to Compare Two Files in the Command Line ]]>
                </title>
                <description>
                    <![CDATA[ Software development and maintenance can get complicated sometimes. And you might find yourself comparing code or configuration changes.  When you compare them manually, you might make a mistake, and it's easy to miss minute changes. Apart from that,... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/compare-two-files-in-linux-using-vim/</link>
                <guid isPermaLink="false">66adea2bc537123a64ede7fa</guid>
                
                    <category>
                        <![CDATA[ command line ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Linux ]]>
                    </category>
                
                    <category>
                        <![CDATA[ vim ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Zaira Hira ]]>
                </dc:creator>
                <pubDate>Mon, 08 Aug 2022 20:08:39 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/08/Copy-of-Cast-a-Function-in-SQL---Convert-Char-to-Int-SQL-Server-Example--3-.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Software development and maintenance can get complicated sometimes. And you might find yourself comparing code or configuration changes. </p>
<p>When you compare them manually, you might make a mistake, and it's easy to miss minute changes. Apart from that, finding changes in large files can be exhausting. </p>
<p>There are many online tools and text editors that help you efficiently compare files. But there is an easier, hassle-free method to compare files using the Linux command line. </p>
<p>The Linux command line is very powerful and provides a file comparison utility within <code>vim</code> to differentiate files side by side.</p>
<p>Learning file comparison in the command line is helpful because many servers use only a CLI (Command Line Interface). This means that you don't have the luxury of a GUI where you can run the browser or other text editors.</p>
<h2 id="heading-what-is-vimdiff">What is vimdiff?</h2>
<p><code>Vimdiff</code> is a Linux command that can edit two, three, or four versions of a file with <code>Vim</code> and show their differences.</p>
<h3 id="heading-vimdiff-syntax"><code>Vimdiff</code> syntax</h3>
<p>For comparing two files, the syntax is the following:</p>
<pre><code class="lang-bash"> vimdiff [options] file1 file2
</code></pre>
<p>Let's compare two files <code>index.js</code> and <code>index.js.bkp</code> to see their differences.</p>
<pre><code class="lang-bash">vimdiff index.js index.js.bkp
</code></pre>
<p><strong>Output:</strong></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/08/image-13.png" alt="Image" width="600" height="400" loading="lazy">
<em><code>Vimdiff</code> output</em></p>
<p>Here we can see the difference in the highlighted line. </p>
<p>To make things easier, we can show the line number as well. When you are in <code>Vim</code>, go to the extended command mode by pressing escape twice and typing <code>:set number</code>. This will reveal the line numbers for the current session.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/08/image-14.png" alt="Image" width="600" height="400" loading="lazy">
<em>Line numbers in <code>vim</code></em></p>
<p>Let's have a closer look at the output again:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/08/image-16.png" alt="Image" width="600" height="400" loading="lazy">
<em>Detailed output of <code>vimdiff</code>.</em></p>
<ul>
<li><strong>Uncollapsed lines:</strong> These are the lines of codes that have not been changed. these are wrapped and can be uncollapsed using a combination of the <code>z+c</code> and <code>z+o</code> keys.</li>
<li><strong>Highlighted changes:</strong> These are the differences present in a file.</li>
<li><strong>Line numbers:</strong> These are the corresponding line numbers in files.</li>
<li><strong>File names:</strong> The file name on the left is the first filename mentioned in the command. The file name on the right is the second filename provided in the command.</li>
</ul>
<p>There is also a way to enable line numbers in Vim by default so you don't have to set it manually each time.</p>
<h3 id="heading-how-to-show-line-numbers-by-default-in-vim-on-linux">How to show line numbers by default in Vim on Linux</h3>
<p>If you like to view line numbers by default in <code>Vim</code>, you can follow these steps:</p>
<ol>
<li>Locate the <code>vimrc</code> file.</li>
</ol>
<p><code>Vim</code> configurations are present in the <code>vimrc</code> file. The file location might vary from one Linux distribution to the other. In Ubuntu, the <code>vimrc</code> file is located in <code>/usr/share/vim/</code>.</p>
<ol start="2">
<li>Edit the <code>vimrc</code> file.</li>
</ol>
<p>Simply append <code>set number</code> in the file and save and exit.</p>
<p>Now whenever you open <code>Vim</code>, the line numbers will be there by default. </p>
<h2 id="heading-vimdiff-operations"><code>Vimdiff</code> Operations</h2>
<p>Let's see how we can utilize the powers of <code>vimdiff</code>. </p>
<p>First, make sure you are in the command mode.</p>
<p>You can go into the command mode by pressing the <code>escape</code> key twice.</p>
<h3 id="heading-how-to-split-screens-horizontally">How to split screens horizontally</h3>
<p>By default, <code>vimdiff</code> splits the screen vertically. If you like to see the files split horizontally, you can use the flag <code>-o</code> like this:</p>
<pre><code class="lang-bash">vimdiff -o index.js index.js.bkp
</code></pre>
<p><strong>Output:</strong></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/08/image-17.png" alt="Image" width="600" height="400" loading="lazy">
<em>Horizontal split</em></p>
<h3 id="heading-how-to-navigate-in-diff-window">How to navigate in diff window</h3>
<ul>
<li>Navigate between diff windows</li>
</ul>
<p>To navigate between panes, use a key combination of <code>Ctrl+W+W</code>. The cursor will switch between the files once you press the keys.</p>
<ul>
<li>Jump to changes</li>
</ul>
<p>Instead of scrolling down line by line and scanning for the changes, you can jump to the change with a specific key combination. </p>
<ol>
<li>To move to the previous change use: <code>[ + c</code>.</li>
<li>To move to the previous change use: <code>] + c</code></li>
</ol>
<h3 id="heading-how-to-apply-changes-from-diff-window">How to apply changes from diff window</h3>
<ul>
<li>To apply changes from the left file to the right file:</li>
</ul>
<p>To apply the changes from the left file to the right file, first, move to the highlighted change. Then, use the command:</p>
<p><code>:diffput</code></p>
<p>Remember that you'll need to be in the command mode.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/08/image-18.png" alt="Image" width="600" height="400" loading="lazy">
<em>Using <code>diffput</code> to apply changes from left to right.</em></p>
<ul>
<li>To apply changes from the right file to the left file:</li>
</ul>
<p>To apply the changes from the right file to the left file, first, move to the highlighted change. Then, use the command:</p>
<p><code>:diffget</code></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/08/image-19.png" alt="Image" width="600" height="400" loading="lazy">
<em>Using <code>diffget</code> to apply changes from right to left.</em></p>
<h3 id="heading-how-to-undo-changes">How to undo changes</h3>
<p>If you make a mistake, you can undo the changes provided you didn't save the file.</p>
<p>When you are in the command mode press <code>u</code> to undo the last change.</p>
<p>If you've recently undone a change, you won't be able to see the highlighted changes as before. You'll need to refresh to see the changes once again. You can do this by using the command:</p>
<p><code>:diffupdate</code></p>
<h3 id="heading-how-to-open-and-close-folds">How to open and close folds</h3>
<p>The unchanged lines are wrapped to provide better readability. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/08/image-33.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>To view the uncollapsed lines as shown above, move the cursor there and use the following key combinations:</p>
<ul>
<li>To open the folds: <code>z + o</code>.</li>
<li>To close the folds: <code>z + c</code>.</li>
</ul>
<h3 id="heading-how-to-exit-the-diff-window">How to exit the diff window</h3>
<p>There are many ways to exit the diff window depending on the end result.</p>
<ul>
<li><code>:qa</code> to exit all the files without saving.</li>
<li><code>:q</code> to exit the files one by one without saving.</li>
<li><code>:wq!</code> to save and exit files one by one.</li>
</ul>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Comparing files is easy and fast with <code>vimdiff</code> as we compare files within the command line. In this tutorial, you learned how to use the <code>vimdiff</code> command to efficiently find differences in code or configuration files. </p>
<p>I hope you found this tutorial helpful. Thank you for reading till the end.</p>
<p>What’s your favorite thing you learned from this tutorial? Let me know on <a target="_blank" href="https://twitter.com/hira_zaira">Twitter</a>!</p>
<p>You can also read my other posts <a target="_blank" href="https://www.freecodecamp.org/news/author/zaira/">here</a>.</p>
<p><sub>Image credits:
Programming vector created by storyset - www.freepik.com</sub></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Learn Vim – Beginner's Tutorial ]]>
                </title>
                <description>
                    <![CDATA[ Vim is a highly configurable text editor that you can use for software development or any kind of text editing.  We just published a full Vim course on the freeCodeCamp.org YouTube channel that will teach you how to use Vim. Florian Dedov from Neural... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/learn-vim-beginners-tutorial/</link>
                <guid isPermaLink="false">66b205634818b8d659cc8140</guid>
                
                    <category>
                        <![CDATA[ vim ]]>
                    </category>
                
                    <category>
                        <![CDATA[ youtube ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Beau Carnes ]]>
                </dc:creator>
                <pubDate>Wed, 09 Mar 2022 16:02:23 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/03/vim.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Vim is a highly configurable text editor that you can use for software development or any kind of text editing. </p>
<p>We just published a full Vim course on the freeCodeCamp.org YouTube channel that will teach you how to use Vim.</p>
<p>Florian Dedov from NeuralNine developed this course.</p>
<p>When someone masters Vim, they can often be more efficient with it than using other text editors. Vim forces you to use only the keyboard and no mouse. This limits the time you waste moving your hand between devices. </p>
<p>Another great thing about Vim is that it can be installed anywhere and comes preinstalled on many machines. If you need to SSH into a Linux box, Vim is often one of the only text editors available.</p>
<p>In this course you will learn how to use all the most common Vim commands and some common Vim extensions. You will even learn how to exit Vim.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/03/image-35.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Watch the full course below or <a target="_blank" href="https://youtu.be/RZ4p-saaQkc">on the freeCodeCamp.org YouTube channel</a> (1-hour watch).</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/RZ4p-saaQkc" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ The 5 Best Code Editors for Mac – MacOS Text Editor Guide ]]>
                </title>
                <description>
                    <![CDATA[ By Dillion Megida When you're coding, you're writing various text that can be executed by different language compilers. And what makes this text fun and easy to write are the editors that we use. Different editors have different features. But they ha... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/the-5-best-code-editors-for-mac-macos-text-editor-guide/</link>
                <guid isPermaLink="false">66d84f6063d2055c664a1a5d</guid>
                
                    <category>
                        <![CDATA[ editor ]]>
                    </category>
                
                    <category>
                        <![CDATA[ ide ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Integrated Development Environment   ]]>
                    </category>
                
                    <category>
                        <![CDATA[ macOS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ vim ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Visual Studio Code ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Mon, 28 Feb 2022 14:46:44 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/02/pexels-negative-space-169573.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Dillion Megida</p>
<p>When you're coding, you're writing various text that can be executed by different language compilers. And what makes this text fun and easy to write are the editors that we use.</p>
<p>Different editors have different features. But they have a common goal: making writing code easier – easier to compose, debug, and read.</p>
<p>In this article, we'll look at five code editors that can improve development on your Mac device.</p>
<h2 id="heading-1-sublime-text">1. Sublime Text</h2>
<p><a target="_blank" href="https://www.sublimetext.com/">Sublime Text</a> is a lightweight editor with many features for improving your code-writing experience. Here are some of its features:</p>
<h3 id="heading-multiple-view-panes">Multiple view panes</h3>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/02/image-92.png" alt="Image" width="600" height="400" loading="lazy">
<em><a target="_blank" href="https://forum.sublimetext.com/t/follow-mode-for-sublime/5100/4">Multiple view panes</a></em></p>
<p>Sublime Text offers multiple view panes for writing code. This way, you can view multiple files at once. </p>
<p>What's more fun is you can open the same file in two panes. This feature can be helpful when you're writing code in a file with long lines of code, as you'll be able to scroll to the top in one pane and then write in the bottom of the other.</p>
<h3 id="heading-side-by-side-view-for-type-definitions">Side-by-side view for Type Definitions</h3>
<p>Instead of just viewing type definitions in a small popup or opening the definition file that overrides the current view, Sublime Text provides a side-by-side view of a definition file for the types in the current file.</p>
<h3 id="heading-multiple-selections">Multiple Selections</h3>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/02/image-93.png" alt="Image" width="600" height="400" loading="lazy">
<em><a target="_blank" href="https://medium.com/sweetmeat/multi-line-selection-text-entry-with-sublime-text-77f226812324">Multi-Line Selection Text Entry with Sublime Text</a></em></p>
<p>There are two forms of multi-selections: multi-selecting the same characters or different characters.</p>
<h4 id="heading-same-character-selection">Same character selection</h4>
<p>Say you want to rename a literal (variable, function, and so on) in multiple places. Sublime Text allows you to highlight the literal, and using <code>Ctrl/Cmd D</code> you can select other occurrences of that literal and edit, replace, or do what you want.</p>
<h4 id="heading-different-characters-selection">Different characters selection</h4>
<p>Maybe some literals are spelled differently, but you want to highlight them together. Sublime allows you to use your mouse to highlight many things at once and operate on them as you choose.</p>
<h2 id="heading-2-vscode">2. VSCode</h2>
<p>The <a target="_blank" href="https://code.visualstudio.com/">VSCode</a> editor offers syntax light, <a target="_blank" href="https://code.visualstudio.com/docs/editor/intellisense#:~:text=IntelliSense%20is%20a%20general%20term,%2C%20and%20%22code%20hinting.%22">IntelliSense</a> features (autocompletes, code hinting, and more), custom configurations, and room for different plugins. VSCode also allows multiple selections and multiple view panes.</p>
<p>Here are more features of VSCode:</p>
<h3 id="heading-code-debugging">Code Debugging</h3>
<p>With VSCode, you do not need to debug on your browser or other tools.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/02/image-94.png" alt="Image" width="600" height="400" loading="lazy">
<em><a target="_blank" href="https://code.visualstudio.com/docs/editor/debugging">Debugging in Visual Studio Code</a></em></p>
<p>VSCode allows you to debug right from your editor using breakpoints, the call stack, and even an interactive console.</p>
<h3 id="heading-many-extensions-for-different-things">Many extensions for different things</h3>
<p>VSCode has a <a target="_blank" href="https://www.freecodecamp.org/news/p/fbff585a-bfcd-44e5-8a3a-024bb1eb2774/Extensions%20for%20Visual%20Studio%20family%20of%20products%20|%20Visual%20Studio%20Marketplace">large marketplace</a> for different languages, frameworks, and even your editor. You have extensions that beautify your editor's appearance and experience and tools that help with autocompletion when writing code.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/02/image-95.png" alt="Image" width="600" height="400" loading="lazy">
<em><a target="_blank" href="https://code.visualstudio.com/docs/editor/extension-marketplace">Managing Extensions in Visual Studio Code</a></em></p>
<h3 id="heading-built-in-terminal">Built-in Terminal</h3>
<p>With VSCode, you have a a built-in shell terminal where you can execute commands without leaving your editor to go to a different terminal app. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/02/image-97.png" alt="Image" width="600" height="400" loading="lazy">
<em>The terminal view of VSCode</em></p>
<p>A small screen may make your editing view small and a bit inconvenient, but with a large monitor, for example, the view is just okay.</p>
<p>VSCode also has multiple view panes, character selection, and multiple character replacements.</p>
<h2 id="heading-3-atom">3. Atom</h2>
<p><a target="_blank" href="https://atom.io/">Atom</a> is a highly customizable code editor. This is why the team calls it a "hackable text editor". From the appearance and colors on the editor to the key combinations for commands and many other things, you can customize Atom as much as you wish and make it very personalized.</p>
<p>Here are some features:</p>
<h3 id="heading-real-time-code-collaboration">Real-time Code Collaboration</h3>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/02/image-98.png" alt="Image" width="600" height="400" loading="lazy">
<em><a target="_blank" href="https://teletype.atom.io/">Teletype for Atom</a></em></p>
<p>Atom has a <a target="_blank" href="https://teletype.atom.io/">Teletyping</a> feature that allows multiple people to work on a codebase in real-time. This feature improves collaboration in a team workspace on projects. For VSCode, you'll usually need an extension for this.</p>
<h3 id="heading-git-integration">Git Integration</h3>
<p>With Atom, you never have to go to your terminal for your Git operations.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/02/image-99.png" alt="Image" width="600" height="400" loading="lazy">
<em><a target="_blank" href="https://github.atom.io/">GitHub for Atom</a></em></p>
<p>Git actions are integrated into Atom using the GitHub package, and this creates a smooth version control experience while you write code.</p>
<h3 id="heading-smart-autocompletion">Smart Autocompletion</h3>
<p>With many languages and syntaxes integrated into Atom, you also get a nice auto-completion feature while writing code.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/02/image-100.png" alt="Image" width="600" height="400" loading="lazy">
<em><a target="_blank" href="https://flight-manual.atom.io/using-atom/sections/autocomplete/">Autocomplete (atom.io)</a></em></p>
<p>You don't have to type out those long method and variable names anymore. Atom's smart enough to help you avoid that 😉.</p>
<p>In Atom, you also have search and replace features, view panes, and more.</p>
<h2 id="heading-4-webstorm">4. WebStorm</h2>
<p><a target="_blank" href="https://www.jetbrains.com/webstorm/">WebStorm</a> calls itself "The Smartest JavaScript IDE". It takes a lot of confidence to call itself that, and WebStorm actually delivers. WebStorm makes writing JavaScript and its related technologies not just convenient but more enjoyable.</p>
<p>Some features include:</p>
<h3 id="heading-built-in-developer-tools">Built-in developer tools</h3>
<p>WebStorm takes the name "development editor" quite literally. From running scripts to breakpoints and general debugging, WebStorm provides developer tools that allow you to write, execute and debug your code.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/02/image-101.png" alt="Image" width="600" height="400" loading="lazy">
<em><a target="_blank" href="https://www.jetbrains.com/webstorm/features/#integrated-developer-tools">WebStorm: Integrated Developer Tools</a></em></p>
<h3 id="heading-smart-features">Smart features</h3>
<p>This editor allows you to move files between folders seamlessly. It also helps you refactor your code and suggest fixes for errors. </p>
<p>And the most brilliant feature I love about it is that you can easily rename a specific variable across your application. Say you have a variable you've imported in many files – you can easily rename that variable from one of the files.</p>
<h3 id="heading-fast-search-and-navigation">Fast search and navigation</h3>
<p>Another fantastic feature of WebStorm, which people generally praise it for, is the fast file or folder search and navigation.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/02/image-102.png" alt="Image" width="600" height="400" loading="lazy">
<em><a target="_blank" href="https://www.jetbrains.com/webstorm/features/#navigation-and-search">WebStorm: Navigation and Search</a></em></p>
<p>From searching file names, class names, function names within files, and special selectors, you can easily find a file you're looking for.</p>
<p>There's also collaboration, view panes, search and replace in WebStorm.</p>
<h2 id="heading-5-vim">5. Vim</h2>
<p>And there's <a target="_blank" href="https://www.vim.org/">Vim</a>. It's worth noting that Vim is not for everyone, as it arguably has a steep learning curve – but Vim has many features that make it worth trying out. I have a friend who's never letting go of Vim and keeps advocating that people are missing out.</p>
<p>Here are some features:</p>
<h3 id="heading-high-customizability">High Customizability</h3>
<p>I mentioned earlier that Atom is highly customizable, but I don't think it's as flexible as Vim.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/02/image-103.png" alt="Image" width="600" height="400" loading="lazy">
<em><a target="_blank" href="https://github.com/fatih/subvim">Vim customized to be like SublimeText</a></em></p>
<p>Down to the low-level commands and feel of the editor, you can configure many things that makes using another editor very strange for you. You can also create scripts that automate things for you.</p>
<h3 id="heading-support-for-many-languages-and-file-formats">Support for Many Languages and File Formats</h3>
<p>Vim has support for many languages and files of different kinds. It also integrates with many tools.</p>
<h3 id="heading-powerful-search-feature">Powerful search feature</h3>
<p>With powerful selectors and regex, you can do multi-level file searches and replacements. With Vim's scripts, you can also get plugins that take the search features to another level.</p>
<p>Agreed, it's not very easy to learn. But it's pretty powerful and consumes less memory, surprisingly. It also has an extensive <a target="_blank" href="https://www.vim.org/scripts/script_search_results.php">script system</a> that gives you much power while writing code.</p>
<h2 id="heading-wrapping-up">Wrapping Up</h2>
<p>There you have it - five code editors you can use to write cleaner, more readable code. I hope you find the one that best fits your needs!</p>
<p>Thanks for reading :)</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Exit Vim – Vim Save and Quit Command Tutorial ]]>
                </title>
                <description>
                    <![CDATA[ By Xing Liu I've been using Vim since the first year I started coding. For all the IDEs/editors that I have used, the Vim plugin is always the very first plugin that I install. I know that Vim can be challenging to work in for people who are not fami... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-exit-vim/</link>
                <guid isPermaLink="false">66d4617373634435aafceff5</guid>
                
                    <category>
                        <![CDATA[ Productivity ]]>
                    </category>
                
                    <category>
                        <![CDATA[ vim ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Mon, 21 Jun 2021 21:52:43 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2021/06/exit-vim-image.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Xing Liu</p>
<p>I've been using Vim since the first year I started coding. For all the IDEs/editors that I have used, the Vim plugin is always the very first plugin that I install.</p>
<p>I know that Vim can be challenging to work in for people who are not familiar with it. In this article, we'll cover some fundamental topics like how to exit Vim, rather than <em>quitting</em> Vim.</p>
<p>I will also include the command that you can use to reveal the corresponding help documentation. To do that, first we need to press <code>ESC</code> a few times, and run the command provided, for example, <code>:h vim-modes</code>, and press <code>Enter</code>.</p>
<h2 id="heading-tldr-how-to-exit-vim">TL;DR – How to Exit Vim</h2>
<ol>
<li>Press <kbd>ESC</kbd> once (<em>sometimes twice</em>)</li>
<li>Make sure you are using the English input method</li>
<li>The next step depends on the current status and your expectations:<ul>
<li>If you didn't make any changes, type <code>:q</code> and press <kbd>Enter</kbd>/<kbd>return</kbd></li>
<li>If you made some changes and would like to <strong>keep</strong> them, type <code>:wq</code> and press <kbd>Enter</kbd>/<kbd>return</kbd></li>
<li>If you made some changes and would rather <strong>discard</strong> them, type <code>:q!</code> and press <kbd>Enter</kbd>/<kbd>return</kbd></li>
</ul>
</li>
</ol>
<p>If you want to understand in more detail how this works, let's dive in.</p>
<h2 id="heading-what-are-modes-in-vim">What are Modes in Vim?</h2>
<p>There are seven BASIC modes in Vim and seven additional modes that are considered variants of the BASIC modes. You may run <code>:h vim-modes</code> inside Vim to read the documentation if you would like to know more.</p>
<p>Fortunately, we don't have to know all of them in order to get started. But there are three modes that we need to be aware of: <code>Normal Mode</code>, <code>Insert Mode</code>, and <code>Command-line Mode</code>.</p>
<h3 id="heading-what-is-normal-mode-in-vim">What is normal mode in Vim?</h3>
<p><code>Normal Mode</code> is crucial since it's only in <code>Normal Mode</code> that we can run commands (there are exceptions but those are beyond the scope of this article). </p>
<p>Say, if we want to read the documentation of <code>vim-modes</code>, then we have to first make sure we are in <code>Normal Mode</code> before typing in <code>:h vim-modes</code>. And the most canonical way of entering <code>Normal Mode</code> is by pressing <code>ESC</code>. Even if you are already in <code>Normal Mode</code>, pressing <code>ESC</code> will keep you in <code>Normal Mode</code>, so no worries. </p>
<p>Find it in the Documentation: <code>:h Normal</code>, <code>:h mode-switching</code>.</p>
<h3 id="heading-what-is-insert-mode-in-vim">What is insert mode in Vim?</h3>
<p>You use <code>Insert Mode</code> to edit the current file (in Vim, this is normally referred to as <code>buffer</code>). By default, we are in the <code>Normal Mode</code> right after we open a file. If we need to make changes to the current file, first we need to switch to <code>Insert Mode</code>. </p>
<p>The most common way to make this switch is by pressing <code>i</code> in <code>Normal mode</code> after navigating the cursor to the place that we are going to edit. </p>
<p>There are actually many other ways to enter <code>Insert Mode</code> as well, like <code>o</code>, <code>O</code>, <code>a</code>, <code>A</code>, <code>I</code>, and so on. </p>
<p>Find it in the Documentation: <code>:h Insert</code>, <code>:h i_&lt;Esc&gt;</code>, <code>:h o</code>, <code>:h O</code>, <code>:h a</code>, <code>:h A</code>, <code>:h I</code>.</p>
<h3 id="heading-what-is-command-line-mode-in-vim">What is command-line mode in Vim?</h3>
<p><code>Command-line Mode</code> is normally a "short-lived" mode, which you use to run "Ex commands" (not to be confused with the "commands" in <code>Normal Mode</code>). </p>
<p>Fun fact: Vim is actually a contraction of <code>Vi Improved</code> and it is based on another text editor named <code>[vi](https://en.wikipedia.org/wiki/Vi)</code>. And <code>vi</code> is based on a line editor named <code>[ex](https://en.wikipedia.org/wiki/Ex_(text_editor))</code>. Both <code>vi</code> and <code>ex</code> were developed by <a target="_blank" href="https://en.wikipedia.org/wiki/Bill_Joy">Bill Joy</a>. </p>
<p>Another fun fact for macOS users: there is only <code>Vim</code> on macOS and the command <code>vi</code> is symlinked to <code>vim</code>. Also note that the "Ex command" in <code>Command-line Mode</code> is different from the "command" in <code>Normal Mode</code>. </p>
<p>You can enter <code>Command-line Mode</code> by typing <code>:</code> in <code>Normal Mode</code>. For example, if you run the commands above to see the documentation, you are actually using the <code>Command-line Mode</code> as soon as you type in <code>:</code>. </p>
<p>Similarly, press <code>ESC</code> if you'd like to switch back to <code>Normal Mode</code>. </p>
<p>Find it in the Documentation: <code>:h Command-line</code>, <code>:h cmdline-lines</code>. </p>
<h2 id="heading-how-to-exit-vim">How to Exit Vim</h2>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/06/image-169.png" alt="Image" width="600" height="400" loading="lazy">
<em>documentation of <code>:h quit</code></em></p>
<p>If you take a look at the documentation of <code>:h quit</code>, note that the <code>quit</code> is prefixed with <code>:</code>. This means that <code>quit</code> is used within <code>Command-line Mode</code>. </p>
<p>In order to enter <code>Command-line Mode</code>, first we need to make sure we are in <code>Normal Mode</code>, then simply type in <code>:</code>. Now that we are in <code>Command-line Mode</code>, just type in <code>quit</code> and press <code>Enter</code> or <code>return</code>. </p>
<p>You may also notice the <code>:q</code> there, which is actually the shorthand version of the <code>:quit</code> command. That being said, we can also quit Vim by executing <code>:q</code> .</p>
<p>It does mention, though, that this command will fail "when changes have been made and Vim refuses to abandon the current buffer" (if you still remember, buffer is just opened file(s), nothing fancy). </p>
<p>In this case, we'd need to use <code>:wq</code>, which means "write and quit". You can find this in the Documentation under <code>:h :wq</code>.</p>
<p><code>:x</code> is another command that works <strong>almost the same</strong> as <code>:wq</code>. According to <code>:h :x</code>, it is "like :wq, but write only when changes have been made". </p>
<p>The difference here is that <code>:wq</code> will save the file no matter if you made changes to it or not. <code>:x</code> won't save the file if you didn't make any changes. What matters here is the modification time of a file, since <code>:wq</code> will update the modification time but <code>:x</code> will not.</p>
<p>There are some times that we'd rather not keep the changes that we've made. At this point, we need the <code>:q!</code> command. The <code>!</code> is normally referred to as "bang", which makes <code>q!</code> something like "force quit". </p>
<p>Do note that if you use this way, you WILL lose all changes that you have made to this file and there is <em>almost</em> no way that you can recover them.</p>
<h2 id="heading-how-to-troubleshoot-exiting-vim">How to Troubleshoot Exiting Vim</h2>
<h3 id="heading-what-if-i-dont-want-to-enter-command-line-mode">What if I don't want to enter <code>Command-line Mode</code>?</h3>
<p>Not a problem. In <code>Normal Mode</code>, you can also press <code>ZZ</code> or <code>ZQ</code> to quit Vim. Where <code>ZZ</code> is the same as <code>:x</code> and <code>ZQ</code> is the same as <code>:q!</code>. </p>
<p>Here, <code>ZZ</code> and <code>ZQ</code> are considered commands of <code>Normal Mode</code> while <code>:x</code> and <code>:q!</code> are Ex commands.</p>
<h3 id="heading-what-if-wq-failed">What if <code>:wq</code> failed?</h3>
<p>This is legit since <code>:wq</code> could fail when the file is read-only or the file name is missing. </p>
<p>Note that when a file is read-only, Vim won't stop you from opening and editing the file. You may also find that <code>:wq!</code> won't work either at that moment. You might end up discarding all changes with <code>:q!</code> and open the same file prefixed with <code>sudo</code> and do the same changes one more time.</p>
<p>One thing you could do is to save this file in another directory that you have write permission to, like <code>~</code> or even <code>/tmp</code>. Then move it back to the directory where you don't have write permission. </p>
<p>In order to achieve this, you can run <code>:w ~/my-backup-file</code> which will save this file under <code>~</code>. Next you can use the <code>mv</code> command to move this file around. Also note that this is what you need to do when Vim complains that the file name is missing.</p>
<p>There is another solution right inside Vim. You could run this command: <code>:w !sudo tee %</code>. Here <code>!sudo</code> means to run the sudo command in your shell environment. </p>
<p>For example, <code>:ls</code> will list all buffers in Vim but <code>:!ls</code> will run the <code>ls</code> command from the shell and display the result. <code>tee</code> copies from standard input (a.k.a. <code>stdin</code>) to standard output (a.k.a. <code>stdout</code>). <code>%</code> refers to the current filename. </p>
<p>This means that we use the <code>sudo</code> command from the shell environment, copy the content of the current file (note: modified version) from Vim, and redirect the modified content to the file (which is referred to by using the filename).</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/06/image-170.png" alt="Image" width="600" height="400" loading="lazy">
<em>Warning of file content change</em></p>
<p>You will notice the warning above. This warning happens because the file content was updated within the shell environment without Vim's attention. So Vim considers this to be an external change and lets you know what happened. </p>
<p>You can just press <code>Enter</code> at this time since you made the external change on purpose.</p>
<p>You may also notice that the modified file content also shows up above the warning message. This is as expected since it comes from the <code>stdout</code>. If you don't want to see it, you may do <code>:w !sudo tee% &gt;/dev/null</code>, which will discard the <code>stdout</code> from <code>tee</code>.</p>
<h3 id="heading-what-if-i-am-lost-and-have-to-force-quit">What if I am lost and have to force-quit?</h3>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/06/image-171.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Well if we try exiting by pressing <code>control + c</code>, Vim will show us the above info. But you may still get around this by <code>Ctrl + Alt + Delete</code> on Windows or <code>Force Quit...</code> on macOS.</p>
<p>Next time when you try to open the same file again, you <em>should</em> see this (here I am using a file named <code>foo.txt</code> as an example):</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/06/image-173.png" alt="Image" width="600" height="400" loading="lazy">
<em>swap file</em></p>
<p>Don't panic – this is as expected, since Vim is trying to help you recover your valuable changes that you might have lost. </p>
<p>By checking the directory, you will find a file with the extension of <code>.swp</code>. This is a <code>swap</code> file (documentation: <code>:h swap-file</code>): </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/06/image-174.png" alt="Image" width="600" height="400" loading="lazy">
<em>swap file .swp</em></p>
<p>We will see the following if we press <code>R</code> to recover:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/06/image-177.png" alt="Image" width="600" height="400" loading="lazy">
<em>.swp recover</em></p>
<p>After pressing <code>Enter</code>, now you'll notice that the changes you made earlier are back. And after you are done with the recover process, you can simply remove the <code>.swp</code> file so that you won't see the error above anymore.</p>
<h2 id="heading-conclusion"><strong>Conclusion</strong></h2>
<p>In this article, we covered some fundamentals about Vim's modes and how to exit Vim. We also learned how to solve common issues when it comes to exiting Vim.</p>
<p>Thanks for reading. There is lot more to learn when it comes to Vim. But feel free to explore the Vim help documentation if you would like to learn more.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Vimrc Configuration Guide - How to Customize Your Vim Code Editor with Mappings, Vimscript, Status Line, and More ]]>
                </title>
                <description>
                    <![CDATA[ By Brandon Wallace Configuring your .vimrc file lets you use the full power of Vim. With a customized .vimrc file you can increase your Vim powers tenfold. In this article I will show you a few ways you can customize your .vimrc file. I will go over:... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/vimrc-configuration-guide-customize-your-vim-editor/</link>
                <guid isPermaLink="false">66d84e55ec0a9800d5b8e6b7</guid>
                
                    <category>
                        <![CDATA[ editor ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Productivity ]]>
                    </category>
                
                    <category>
                        <![CDATA[ self-improvement  ]]>
                    </category>
                
                    <category>
                        <![CDATA[ vim ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Wed, 02 Jun 2021 20:44:22 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2021/06/cover_image.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Brandon Wallace</p>
<p>Configuring your .vimrc file lets you use the full power of Vim. With a customized .vimrc file you can increase your Vim powers tenfold.</p>
<p>In this article I will show you a few ways you can customize your .vimrc file.</p>
<p>I will go over:</p>
<ul>
<li>Basic Settings</li>
<li>Plugins</li>
<li>Folding</li>
<li>Vimscript</li>
<li>Status line</li>
</ul>
<p>First create the following directory structure in your home directory.</p>
<pre><code class="lang-bash">.vim/
 ├── <span class="hljs-built_in">autoload</span>/
 ├── backup/
 ├── colors/
 └── plugged/
</code></pre>
<pre><code>$ mkdir -p ~<span class="hljs-regexp">/.vim ~/</span>.vim/autoload ~<span class="hljs-regexp">/.vim/</span>backup ~<span class="hljs-regexp">/.vim/</span>colors ~<span class="hljs-regexp">/.vim/</span>plugged
</code></pre><p>Create a .vimrc file in your home directory.</p>
<pre><code class="lang-bash">$ touch ~/.vimrc
</code></pre>
<h1 id="heading-how-to-update-basic-settings-in-vim">How to Update Basic Settings in Vim</h1>
<p>First let's add some basic settings that will improve your editing experience. I use double quote characters to comment out lines.</p>
<p>Add the following lines to your .vimrc file:</p>
<pre><code class="lang-vimrc">" Disable compatibility with vi which can cause unexpected issues.
set nocompatible

" Enable type file detection. Vim will be able to try to detect the type of file in use.
filetype on

" Enable plugins and load plugin for the detected file type.
filetype plugin on

" Load an indent file for the detected file type.
filetype indent on
</code></pre>
<p>Syntax highlighting is very useful. The next line we add will enable syntax highlighting and make your code easier to read.</p>
<pre><code class="lang-vimrc">" Turn syntax highlighting on.
syntax on
</code></pre>
<h3 id="heading-this-is-what-it-looks-like-before">This is what it looks like before:</h3>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/05/vim_no_highlighting.png" alt="vim-no-highlighting.png" width="600" height="400" loading="lazy"></p>
<h3 id="heading-and-after">And after:</h3>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/05/vim_highlighting.png" alt="vim-highlighting.png" width="600" height="400" loading="lazy"></p>
<p>You can also choose to display line numbers to make navigating the file easier.</p>
<pre><code class="lang-vimrc">" Add numbers to each line on the left-hand side.
set number
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/05/set_numbers.png" alt="set-numbers.png" width="600" height="400" loading="lazy"></p>
<p>You can pinpoint exactly where the cursor is located by highlighting the line it is on horizontally and vertically.</p>
<p>Add these lines to enable this feature.</p>
<pre><code><span class="hljs-string">" Highlight cursor line underneath the cursor horizontally.
set cursorline

"</span> Highlight cursor line underneath the cursor vertically.
set cursorcolumn
</code></pre><p><img src="https://www.freecodecamp.org/news/content/images/2021/05/set_cursor-line-column-1.png" alt="set-cursor-line-column.png" width="600" height="400" loading="lazy"></p>
<p>Here are some more common setting that enhance the editing experience.<br>Each line contains a comment above it explaining what it does.</p>
<p>Add the following lines to the .vimrc file.</p>
<pre><code class="lang-vimrc">" Set shift width to 4 spaces.
set shiftwidth=4

" Set tab width to 4 columns.
set tabstop=4

" Use space characters instead of tabs.
set expandtab

" Do not save backup files.
set nobackup

" Do not let cursor scroll below or above N number of lines when scrolling.
set scrolloff=10

" Do not wrap lines. Allow long lines to extend as far as the line goes.
set nowrap

" While searching though a file incrementally highlight matching characters as you type.
set incsearch

" Ignore capital letters during search.
set ignorecase

" Override the ignorecase option if searching for capital letters.
" This will allow you to search specifically for capital letters.
set smartcase

" Show partial command you type in the last line of the screen.
set showcmd

" Show the mode you are on the last line.
set showmode

" Show matching words during a search.
set showmatch

" Use highlighting when doing a search.
set hlsearch

" Set the commands to save in history default number is 20.
set history=1000
</code></pre>
<p>Bash completion is a great feature which saves keystrokes by auto completing what you type. Vim has a similar feature called wildmenu.</p>
<p>Add the following lines to enable the wildmenu feature. You will see a list of files matching the file you are searching for. You can also enable auto completion to Vim.</p>
<pre><code class="lang-vimrc">" Enable auto completion menu after pressing TAB.
set wildmenu

" Make wildmenu behave like similar to Bash completion.
set wildmode=list:longest

" There are certain files that we would never want to edit with Vim.
" Wildmenu will ignore files with these extensions.
set wildignore=*.docx,*.jpg,*.png,*.gif,*.pdf,*.pyc,*.exe,*.flv,*.img,*.xlsx
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/05/vim_wildmenu.gif" alt="vim-wildmenu.gif" width="600" height="400" loading="lazy"></p>
<p>Type <code>:help &lt;command&gt;</code> for more information on specific commands.</p>
<p>Example:</p>
<pre><code>:help nocompatible
</code></pre><h1 id="heading-how-to-fold-long-files-in-vim">How to Fold Long Files in Vim</h1>
<p>The .vimrc file can get long so organizing it into sections is a smart idea.<br>Vim will allow you to fold long files to hide sections of text.</p>
<p>Add the following lines to the bottom of your .vimrc to organize the file into sections.</p>
<pre><code class="lang-vimrc">" PLUGINS ---------------------------------------------------------------- {{{

" Plugin code goes here.

" }}}


" MAPPINGS --------------------------------------------------------------- {{{

" Mappings code goes here.

" }}}


" VIMSCRIPT -------------------------------------------------------------- {{{

" This will enable code folding.
" Use the marker method of folding.
augroup filetype_vim
    autocmd!
    autocmd FileType vim setlocal foldmethod=marker
augroup END

" More Vimscripts code goes here.

" }}}


" STATUS LINE ------------------------------------------------------------ {{{

" Status bar code goes here.

" }}}
</code></pre>
<p>Save the .vimrc file with <code>:w</code> and source the .vimrc file like this <code>:source ~/.vimrc</code> to make the changes take effect. Now, once you move your cursor on a fold you can press:</p>
<p><code>zo</code> to open a single fold under the cursor.</p>
<p><code>zc</code> to close the fold under the cursor.</p>
<p><code>zR</code> to open all folds.</p>
<p><code>zM</code> to close all folds.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/05/vim_open_close_fold.gif" alt="vim-open-close-fold.gif" width="600" height="400" loading="lazy"></p>
<p>Type <code>:help folding</code> for more information.</p>
<h1 id="heading-how-to-add-plugins-to-vim">How to Add Plugins to Vim</h1>
<p>You can add plugins to Vim to add extra functionality. Most people use a plugin manager to make plugin installation easy. </p>
<p>There are a variety of plugin managers we can use. I will show you how to install and use the <a target="_blank" href="https://github.com/junegunn/vim-plug">vim-plug</a> plugin manager.</p>
<p>To install the vim-plug plugin, run this command:</p>
<p>On Linux or Mac OS.</p>
<pre><code class="lang-bash">$ curl -fLo ~/.vim/<span class="hljs-built_in">autoload</span>/plug.vim --create-dirs \
    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
</code></pre>
<p>On Windows with Powershell.</p>
<pre><code class="lang-powershell"><span class="hljs-variable">$</span> <span class="hljs-built_in">iwr</span> <span class="hljs-literal">-useb</span> https://raw.githubusercontent.com/junegunn/vim<span class="hljs-literal">-plug</span>/master/plug.vim |`
    <span class="hljs-built_in">ni</span> <span class="hljs-variable">$HOME</span>/vimfiles/autoload/plug.vim <span class="hljs-literal">-Force</span>
</code></pre>
<p>Add the <code>call plug#begin('~/.vim/plugged')</code> and <code>call plug#end()</code> lines in the plugins section. The plugins we install will be added between the two function calls.</p>
<pre><code><span class="hljs-string">" PLUGINS ---------------------------------------------------------------- {{{

call plug#begin('~/.vim/plugged')




call plug#end()

"</span> }}}
</code></pre><p>Now installing plugins is as easy as adding the <code>Plug 'username/plugin-name'</code> string you find on GitHub in between the function calls.</p>
<p>This is how I install <a target="_blank" href="https://github.com/preservim/nerdtree">NERDTree</a> and <a target="_blank" href="https://github.com/dense-analysis/ale">Asynchronous Lint Engine (ALE)</a>.</p>
<p>Add these two lines in between the two <code>call plug#...</code> lines:</p>
<pre><code><span class="hljs-string">" PLUGINS ---------------------------------------------------------------- {{{

call plug#begin('~/.vim/plugged')


  Plug 'dense-analysis/ale'

  Plug 'preservim/nerdtree'


call plug#end()

"</span> }}}
</code></pre><p>Save the .vimrc file with the command <code>:w</code> and source the .vimrc file with this command <code>:source ~/.vimrc</code> to make the changes take effect.</p>
<p>Now type <code>:PlugInstall</code> to download and install the two plugins.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/05/vim-plug_install.png" alt="vim-plug-install.png" width="600" height="400" loading="lazy"></p>
<h1 id="heading-how-to-map-keyboard-shortcuts-in-vim">How to Map Keyboard Shortcuts in Vim</h1>
<p>In the mapping section we will add shortcuts to making typing longer commands easier. This will save you key strokes and lots of time, especially for long commands.</p>
<p>Key mapping syntax is like this:</p>
<p><code>map_mode &lt;what_you_type&gt; &lt;what_is_executed&gt;</code></p>
<h3 id="heading-popular-mapping-modes-in-vim">Popular Mapping Modes in Vim</h3>
<p>Here are a few popular mapping modes and probably the most useful and important.</p>
<ul>
<li><code>nnoremap</code> – Allows you to map keys in normal mode.</li>
<li><code>inoremap</code> – Allows you to map keys in insert mode.</li>
<li><code>vnoremap</code> – Allows you to map keys in visual mode.</li>
</ul>
<p>A common mapping example is to map 'jj' to the escape key. You will be pressing the escape key a lot. The escape key is in the far corner of the keyboard.<br>The letter 'j' is in the middle of the keyboard so it is easier to press 'jj' instead of reaching for the escape key.</p>
<p>This is how you would map the escape key to <code>jj</code>.</p>
<p><code>inoremap jj &lt;esc&gt;</code></p>
<h3 id="heading-how-to-use-mapleader-in-vim">How to Use Mapleader in Vim</h3>
<p>Mapleader will allow you set a key unused by Vim as the <code>&lt;leader&gt;</code> key.<br>The leader key, in conjunction with another key, will allow you to create new shortcuts. </p>
<p>The backslash key is the default leader key but some people change it to a comma <code>","</code>.</p>
<p><code>let mapleader = "\"</code></p>
<p>With the leader key mapped to backslash, I can use it like this:</p>
<p>Turn off search highlighting by pressing <code>\\</code>.<br><code>nnoremap &lt;leader&gt;\ :nohlsearch&lt;CR&gt;</code></p>
<p>Here are some common mappings that people use. See the comments above each line for the explanation.</p>
<p>Add this code in the mappings section:</p>
<pre><code class="lang-vimrc">" MAPPINGS --------------------------------------------------------------- {{{

" Set the backslash as the leader key.
let mapleader = "\"

" Press \\ to jump back to the last cursor position.
nnoremap &lt;leader&gt;\ ``

" Press \p to print the current file to the default printer from a Linux operating system.
" View available printers:   lpstat -v
" Set default printer:       lpoptions -d &lt;printer_name&gt;
" &lt;silent&gt; means do not display output.
nnoremap &lt;silent&gt; &lt;leader&gt;p :%w !lp&lt;CR&gt;

" Type jj to exit insert mode quickly.
inoremap jj &lt;Esc&gt;

" Press the space bar to type the : character in command mode.
nnoremap &lt;space&gt; :

" Pressing the letter o will open a new line below the current one.
" Exit insert mode after creating a new line above or below the current line.
nnoremap o o&lt;esc&gt;
nnoremap O O&lt;esc&gt;

" Center the cursor vertically when moving to the next word during a search.
nnoremap n nzz
nnoremap N Nzz

" Yank from cursor to the end of line.
nnoremap Y y$

" Map the F5 key to run a Python script inside Vim.
" I map F5 to a chain of commands here.
" :w saves the file.
" &lt;CR&gt; (carriage return) is like pressing the enter key.
" !clear runs the external clear screen command.
" !python3 % executes the current file with Python.
nnoremap &lt;f5&gt; :w &lt;CR&gt;:!clear &lt;CR&gt;:!python3 % &lt;CR&gt;

" You can split the window in Vim by typing :split or :vsplit.
" Navigate the split view easier by pressing CTRL+j, CTRL+k, CTRL+h, or CTRL+l.
nnoremap &lt;c-j&gt; &lt;c-w&gt;j
nnoremap &lt;c-k&gt; &lt;c-w&gt;k
nnoremap &lt;c-h&gt; &lt;c-w&gt;h
nnoremap &lt;c-l&gt; &lt;c-w&gt;l

" Resize split windows using arrow keys by pressing:
" CTRL+UP, CTRL+DOWN, CTRL+LEFT, or CTRL+RIGHT.
noremap &lt;c-up&gt; &lt;c-w&gt;+
noremap &lt;c-down&gt; &lt;c-w&gt;-
noremap &lt;c-left&gt; &lt;c-w&gt;&gt;
noremap &lt;c-right&gt; &lt;c-w&gt;&lt;

" NERDTree specific mappings.
" Map the F3 key to toggle NERDTree open and close.
nnoremap &lt;F3&gt; :NERDTreeToggle&lt;cr&gt;

" Have nerdtree ignore certain files and directories.
let NERDTreeIgnore=['\.git$', '\.jpg$', '\.mp4$', '\.ogg$', '\.iso$', '\.pdf$', '\.pyc$', '\.odt$', '\.png$', '\.gif$', '\.db$']

" }}}
</code></pre>
<p>Type <code>help: map-modes</code> for more information.</p>
<h1 id="heading-how-to-add-some-vimscripting">How to Add Some Vimscripting</h1>
<p>Vimscript is a scripting language that lets you create scripts using variables, if else statements, and functions. Auto commands are waiting for events to occur in order to trigger a command.</p>
<pre><code class="lang-vimrc">" VIMSCRIPT -------------------------------------------------------------- {{{

" Enable the marker method of folding.
augroup filetype_vim
    autocmd!
    autocmd FileType vim setlocal foldmethod=marker
augroup END

" If the current file type is HTML, set indentation to 2 spaces.
autocmd Filetype html setlocal tabstop=2 shiftwidth=2 expandtab

" If Vim version is equal to or greater than 7.3 enable undofile.
" This allows you to undo changes to a file even after saving it.
if version &gt;= 703
    set undodir=~/.vim/backup
    set undofile
    set undoreload=10000
endif

" You can split a window into sections by typing `:split` or `:vsplit`.
" Display cursorline and cursorcolumn ONLY in active window.
augroup cursor_off
    autocmd!
    autocmd WinLeave * set nocursorline nocursorcolumn
    autocmd WinEnter * set cursorline cursorcolumn
augroup END

" If GUI version of Vim is running set these options.
if has('gui_running')

    " Set the background tone.
    set background=dark

    " Set the color scheme.
    colorscheme molokai

    " Set a custom font you have installed on your computer.
    " Syntax: set guifont=&lt;font_name&gt;\ &lt;font_weight&gt;\ &lt;size&gt;
    set guifont=Monospace\ Regular\ 12

    " Display more of the file by default.
    " Hide the toolbar.
    set guioptions-=T

    " Hide the the left-side scroll bar.
    set guioptions-=L

    " Hide the the right-side scroll bar.
    set guioptions-=r

    " Hide the the menu bar.
    set guioptions-=m

    " Hide the the bottom scroll bar.
    set guioptions-=b

    " Map the F4 key to toggle the menu, toolbar, and scroll bar.
    " &lt;Bar&gt; is the pipe character.
    " &lt;CR&gt; is the enter key.
    nnoremap &lt;F4&gt; :if &amp;guioptions=~#'mTr'&lt;Bar&gt;
        \set guioptions-=mTr&lt;Bar&gt;
        \else&lt;Bar&gt;
        \set guioptions+=mTr&lt;Bar&gt;
        \endif&lt;CR&gt;

endif

" }}}
</code></pre>
<p>Read <a target="_blank" href="https://learnvimscriptthehardway.stevelosh.com/">Learn Vimscript the Hard Way</a> for more information on Vimscript.</p>
<p>Type <code>:help autocmd</code> for more information on auto commands.</p>
<h1 id="heading-how-to-add-color-schemes-to-vim">How to Add Color Schemes to Vim</h1>
<p>You can easily add color schemes to Vim to change the default colors. Do a search for Vim color schemes and you will find many, many choices.</p>
<p>Installing a color scheme is a simple as adding a <code>&lt;colorscheme&gt;.vim</code> file to the <code>~/.vim/colors/</code> directory.</p>
<p>I will add the popular color scheme molokai:</p>
<pre><code class="lang-bash">$ <span class="hljs-built_in">cd</span> ~/.vim/colors

$ curl -o molokai.vim https://raw.githubusercontent.com/tomasr/molokai/master/colors/molokai.vim
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  7558  100  7558    0     0   150k      0 --:--:-- --:--:-- --:--:--  150k
</code></pre>
<p>To set the color scheme, type this command:</p>
<pre><code class="lang-vimrc">:colorscheme molokai
</code></pre>
<h3 id="heading-example-color-schemes">Example color schemes:</h3>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/05/vim_four_colorschemes.png" alt="vim_four_colorschemes" width="600" height="400" loading="lazy">
<em>color schemes: molokai, base16-tomorrow, blue, one</em></p>
<h1 id="heading-how-to-configure-the-status-bar-in-vim">How to Configure the Status Bar in Vim</h1>
<p>You can configure your Vim status bar with useful information. For example, configure the file type, total number of lines in the file, path to the file, column number, row number, percentage through file, and much more.</p>
<p>Add this code in the status line section:</p>
<pre><code class="lang-vimrc">" STATUS LINE ------------------------------------------------------------ {{{

" Clear status line when vimrc is reloaded.
set statusline=

" Status line left side.
set statusline+=\ %F\ %M\ %Y\ %R

" Use a divider to separate the left side from the right side.
set statusline+=%=

" Status line right side.
set statusline+=\ ascii:\ %b\ hex:\ 0x%B\ row:\ %l\ col:\ %c\ percent:\ %p%%

" Show the status on the second to last line.
set laststatus=2

" }}}
</code></pre>
<p><code>%F</code> – Display the full path of the current file.</p>
<p><code>%M</code> – Modified flag shows if file is unsaved.</p>
<p><code>%Y</code> – Type of file in the buffer.</p>
<p><code>%R</code> – Displays the read-only flag.</p>
<p><code>%b</code> – Shows the ASCII/Unicode character under cursor.</p>
<p><code>0x%B</code> – Shows the hexadecimal character under cursor.</p>
<p><code>%l</code> – Display the row number.</p>
<p><code>%c</code> – Display the column number.</p>
<p><code>%p%%</code> – Show the cursor percentage from the top of the file.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/05/vim_statusline.png" alt="vim_statusline" width="600" height="400" loading="lazy"></p>
<p>Type <code>help: statusline</code> for more information.</p>
<p>This is the complete .vimrc file.</p>
<pre><code class="lang-vimrc">"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""               
"               
"               ██╗   ██╗██╗███╗   ███╗██████╗  ██████╗
"               ██║   ██║██║████╗ ████║██╔══██╗██╔════╝
"               ██║   ██║██║██╔████╔██║██████╔╝██║     
"               ╚██╗ ██╔╝██║██║╚██╔╝██║██╔══██╗██║     
"                ╚████╔╝ ██║██║ ╚═╝ ██║██║  ██║╚██████╗
"                 ╚═══╝  ╚═╝╚═╝     ╚═╝╚═╝  ╚═╝ ╚═════╝
"               
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""               

" Disable compatibility with vi which can cause unexpected issues.
set nocompatible

" Enable type file detection. Vim will be able to try to detect the type of file is use.
filetype on

" Enable plugins and load plugin for the detected file type.
filetype plugin on

" Load an indent file for the detected file type.
filetype indent on

" Turn syntax highlighting on.
syntax on

" Add numbers to the file.
set number

" Highlight cursor line underneath the cursor horizontally.
set cursorline

" Highlight cursor line underneath the cursor vertically.
set cursorcolumn

" Set shift width to 4 spaces.
set shiftwidth=4

" Set tab width to 4 columns.
set tabstop=4

" Use space characters instead of tabs.
set expandtab

" Do not save backup files.
set nobackup

" Do not let cursor scroll below or above N number of lines when scrolling.
set scrolloff=10

" Do not wrap lines. Allow long lines to extend as far as the line goes.
set nowrap

" While searching though a file incrementally highlight matching characters as you type.
set incsearch

" Ignore capital letters during search.
set ignorecase

" Override the ignorecase option if searching for capital letters.
" This will allow you to search specifically for capital letters.
set smartcase

" Show partial command you type in the last line of the screen.
set showcmd

" Show the mode you are on the last line.
set showmode

" Show matching words during a search.
set showmatch

" Use highlighting when doing a search.
set hlsearch

" Set the commands to save in history default number is 20.
set history=1000

" Enable auto completion menu after pressing TAB.
set wildmenu

" Make wildmenu behave like similar to Bash completion.
set wildmode=list:longest

" There are certain files that we would never want to edit with Vim.
" Wildmenu will ignore files with these extensions.
set wildignore=*.docx,*.jpg,*.png,*.gif,*.pdf,*.pyc,*.exe,*.flv,*.img,*.xlsx

" PLUGINS ---------------------------------------------------------------- {{{

call plug#begin('~/.vim/plugged')

  Plug 'dense-analysis/ale'

  Plug 'preservim/nerdtree'

call plug#end()

" }}}

" MAPPINGS --------------------------------------------------------------- {{{

" Set the backslash as the leader key.
let mapleader = "\"

" Press \\ to jump back to the last cursor position.
nnoremap &lt;leader&gt;\ ``

" Press \p to print the current file to the default printer from a Linux operating system.
" View available printers:   lpstat -v
" Set default printer:       lpoptions -d &lt;printer_name&gt;
" &lt;silent&gt; means do not display output.
nnoremap &lt;silent&gt; &lt;leader&gt;p :%w !lp&lt;CR&gt;

" Type jj to exit insert mode quickly.
inoremap jj &lt;Esc&gt;

" Press the space bar to type the : character in command mode.
nnoremap &lt;space&gt; :

" Pressing the letter o will open a new line below the current one.
" Exit insert mode after creating a new line above or below the current line.
nnoremap o o&lt;esc&gt;
nnoremap O O&lt;esc&gt;

" Center the cursor vertically when moving to the next word during a search.
nnoremap n nzz
nnoremap N Nzz

" Yank from cursor to the end of line.
nnoremap Y y$

" Map the F5 key to run a Python script inside Vim.
" We map F5 to a chain of commands here.
" :w saves the file.
" &lt;CR&gt; (carriage return) is like pressing the enter key.
" !clear runs the external clear screen command.
" !python3 % executes the current file with Python.
nnoremap &lt;f5&gt; :w &lt;CR&gt;:!clear &lt;CR&gt;:!python3 % &lt;CR&gt;

" You can split the window in Vim by typing :split or :vsplit.
" Navigate the split view easier by pressing CTRL+j, CTRL+k, CTRL+h, or CTRL+l.
nnoremap &lt;c-j&gt; &lt;c-w&gt;j
nnoremap &lt;c-k&gt; &lt;c-w&gt;k
nnoremap &lt;c-h&gt; &lt;c-w&gt;h
nnoremap &lt;c-l&gt; &lt;c-w&gt;l

" Resize split windows using arrow keys by pressing:
" CTRL+UP, CTRL+DOWN, CTRL+LEFT, or CTRL+RIGHT.
noremap &lt;c-up&gt; &lt;c-w&gt;+
noremap &lt;c-down&gt; &lt;c-w&gt;-
noremap &lt;c-left&gt; &lt;c-w&gt;&gt;
noremap &lt;c-right&gt; &lt;c-w&gt;&lt;

" NERDTree specific mappings.
" Map the F3 key to toggle NERDTree open and close.
nnoremap &lt;F3&gt; :NERDTreeToggle&lt;cr&gt;

" Have nerdtree ignore certain files and directories.
let NERDTreeIgnore=['\.git$', '\.jpg$', '\.mp4$', '\.ogg$', '\.iso$', '\.pdf$', '\.pyc$', '\.odt$', '\.png$', '\.gif$', '\.db$']

" }}}

" VIMSCRIPT -------------------------------------------------------------- {{{

" Enable the marker method of folding.
augroup filetype_vim
    autocmd!
    autocmd FileType vim setlocal foldmethod=marker
augroup END

" If the current file type is HTML, set indentation to 2 spaces.
autocmd Filetype html setlocal tabstop=2 shiftwidth=2 expandtab

" If Vim version is equal to or greater than 7.3 enable undofile.
" This allows you to undo changes to a file even after saving it.
if version &gt;= 703
    set undodir=~/.vim/backup
    set undofile
    set undoreload=10000
endif

" You can split a window into sections by typing `:split` or `:vsplit`.
" Display cursorline and cursorcolumn ONLY in active window.
augroup cursor_off
    autocmd!
    autocmd WinLeave * set nocursorline nocursorcolumn
    autocmd WinEnter * set cursorline cursorcolumn
augroup END

" If GUI version of Vim is running set these options.
if has('gui_running')

    " Set the background tone.
    set background=dark

    " Set the color scheme.
    colorscheme molokai

    " Set a custom font you have installed on your computer.
    " Syntax: &lt;font_name&gt;\ &lt;weight&gt;\ &lt;size&gt;
    set guifont=Monospace\ Regular\ 12

    " Display more of the file by default.
    " Hide the toolbar.
    set guioptions-=T

    " Hide the the left-side scroll bar.
    set guioptions-=L

    " Hide the the left-side scroll bar.
    set guioptions-=r

    " Hide the the menu bar.
    set guioptions-=m

    " Hide the the bottom scroll bar.
    set guioptions-=b

    " Map the F4 key to toggle the menu, toolbar, and scroll bar.
    " &lt;Bar&gt; is the pipe character.
    " &lt;CR&gt; is the enter key.
    nnoremap &lt;F4&gt; :if &amp;guioptions=~#'mTr'&lt;Bar&gt;
        \set guioptions-=mTr&lt;Bar&gt;
        \else&lt;Bar&gt;
        \set guioptions+=mTr&lt;Bar&gt;
        \endif&lt;CR&gt;

endif

" }}}

" STATUS LINE ------------------------------------------------------------ {{{

" Clear status line when vimrc is reloaded.
set statusline=

" Status line left side.
set statusline+=\ %F\ %M\ %Y\ %R

" Use a divider to separate the left side from the right side.
set statusline+=%=

" Status line right side.
"set statusline+=\ ascii:\ %b\ hex:\ 0x%B\ row:\ %l\ col:\ %c\ percent:\ %p%%

" Show the status on the second to last line.
set laststatus=2

" }}}
</code></pre>
<h1 id="heading-conclusion">Conclusion</h1>
<p>In this article, I have only scratched the surface of how you can customize Vim.<br>There are thousands of ways to configure and customize a .vimrc to your liking.<br>You can even write your own plugins and color schemes and share them with the world.</p>
<p>I hope that you have learned a new trick or two by reading this article. So if you use Vim, don't leave home without a .vimrc file!</p>
<p>By the way, I used Vim to write this article.</p>
<p>Follow me on <a target="_blank" href="https://github.com/brandon-wallace">Github</a> | <a target="_blank" href="https://dev.to/brandonwallace">DEV.to</a></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Search-and-replace Across Multiple Files in Vim ]]>
                </title>
                <description>
                    <![CDATA[ In this article, you'll learn how to interactively search-and-replace across many files with just two commands, thanks to Vim. While a multitude of methods exist to search for and replace words in a single file, what do you do when you’ve got a strin... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-search-and-replace-across-multiple-files-in-vim/</link>
                <guid isPermaLink="false">66bd8f4d6d46d5e73b73e915</guid>
                
                    <category>
                        <![CDATA[ Productivity ]]>
                    </category>
                
                    <category>
                        <![CDATA[ vim ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Victoria Drake ]]>
                </dc:creator>
                <pubDate>Fri, 28 Aug 2020 15:01:11 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2020/08/cover-5.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>In this article, you'll learn how to interactively search-and-replace across many files with just two commands, thanks to Vim.</p>
<p>While a multitude of methods exist to search for and replace words in a single file, what do you do when you’ve got a string to update across multiple unrelated files, all with different names? You harness the power of command line tools, of course!</p>
<p>First, you’ll need to <code>find</code> all the files you want to change. Stringing together what are effectively search queries for <code>find</code> is really only limited by your imagination. </p>
<p>Here’s a simple example that finds Python files:</p>
<pre><code class="lang-sh">find . -name <span class="hljs-string">'*.py'</span>
</code></pre>
<p>The <code>-name</code> test searches for a pattern, such as all files ending in <code>.py</code>. But <code>find</code> can do a lot more with other test conditions, including <code>-regex</code> tests. Run <code>find --help</code> to see the multitude of options.</p>
<p>Further tune your search by using <code>grep</code> to get only the files that contain the string you want to change, such as by adding:</p>
<pre><code class="lang-sh">grep -le <span class="hljs-string">'\&lt;a whale\&gt;'</span>
</code></pre>
<p>The <code>-l</code> option gives you just the file names for all files containing a pattern (denoted with <code>-e</code>) that match “a whale”.</p>
<p>You can also use Vim’s impressive <code>:bufdo</code> which lets you run the same command across multiple buffers. It interactively works with all of these files without the tedium of opening, saving, and closing each file, one at a time.</p>
<p>Let’s plug your powerful <code>find</code>+<code>grep</code> results into Vim with:</p>
<pre><code class="lang-sh">vim `find . -name <span class="hljs-string">'*.py'</span> \
-<span class="hljs-built_in">exec</span> grep -le <span class="hljs-string">'\&lt;a whale\&gt;'</span> {} \;`
</code></pre>
<p>Using backtick-expansion to pass our search to Vim opens up multiple buffers ready to go. (Do <code>:h backtick-expansion</code> in Vim for more.) </p>
<p>Now you can apply the Vim command <code>:bufdo</code> to all of these files and perform actions such as interactive search-and-replace:</p>
<pre><code class="lang-vim">:bufdo %s/a whale/a bowl of petunias/gce
</code></pre>
<p>The <code>g</code> for “global” will change occurrences of the pattern on all lines. The <code>e</code> will omit errors if the pattern is not found. The <code>c</code> option makes this interactive. If you’re feeling confident, you can omit it to make the changes without reviewing each one.</p>
<p>When you’ve finished going through all the buffers, save all the work you’ve completed with:</p>
<pre><code class="lang-vim">:bufdo wq!
</code></pre>
<p>Then bask in the glory of your saved time and effort.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How I Made VIM's Project-wide Search Seamless with ripgrep ]]>
                </title>
                <description>
                    <![CDATA[ Yes, I ditched grep & the_silver_searcher(ag) for ripgrep. Whether you're forced to use VIM at your workplace or you're a mad VIM fan like I am who obsesses about productivity, the project-wide keyword search is a basic requirement every developer ne... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-search-project-wide-vim-ripgrep-ack/</link>
                <guid isPermaLink="false">66b907fcff5ca4264bc37d19</guid>
                
                    <category>
                        <![CDATA[ Productivity ]]>
                    </category>
                
                    <category>
                        <![CDATA[ vim ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Rahul gupta ]]>
                </dc:creator>
                <pubDate>Mon, 08 Jun 2020 16:57:07 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2020/06/markus-winkler-afW1hht0NSs-unsplash--1-.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Yes, I ditched grep &amp; the_silver_searcher(ag) for ripgrep.</p>
<p>Whether you're forced to use VIM at your workplace or you're a mad VIM fan like I am who obsesses about productivity, the project-wide keyword search is a basic requirement every developer needs in their editor's arsenal. And we expect it to be blazing fast. ⚡️</p>
<p>I've been using VIM for about 3 years now. And coming from a <a target="_blank" href="https://www.sublimetext.com/">Sublime</a> background, the need for project-wide search was essential.</p>
<p><a target="_blank" href="https://github.com/BurntSushi/ripgrep">ripgrep</a> and <a target="_blank" href="https://github.com/mileszs/ack.vim">a</a>ck.vim were things I adopted early on after my unfulfilling experiences with grep and the_silver_searcher(ag). I haven't looked back since then.</p>
<p>This article is the result of experimenting with different search tools and incremental improvements I made over a period of time until it felt just right.</p>
<h2 id="heading-why-ackvim-amp-ripgrep">Why ack.vim &amp; ripgrep?</h2>
<ol>
<li><p><strong>Fast:</strong> I've worked on Symfony and JavaScript projects with thousands of files and it is just blazing fast. Here's a quick <a target="_blank" href="https://github.com/BurntSushi/ripgrep#quick-examples-comparing-tools">comparison</a> with other search tools.<br> My benchmark for speed is, "it should never feel slow". I noticed a tremendous improvement after I moved from grep, the_silver_searcher and ack.</p>
</li>
<li><p><strong>Quick navigation</strong>: ack.vim takes care of populating the Quickfix list, which lets you conveniently move through all those search results across different files.</p>
</li>
<li><p><strong>Sensible defaults:</strong> ripgrep by default considers gitignore and automatically skips hidden files/directories and binary files.</p>
</li>
</ol>
<h2 id="heading-overview">Overview</h2>
<p><strong>ack.vim</strong> is a VIM plugin that acts as a wrapper to search keywords and populate the Quickfix list for navigating the results.</p>
<p><strong>ripgrep (rg)</strong> is a command-line tool that ack.vim will internally use to perform the actual project-wide search.</p>
<h2 id="heading-steps">Steps</h2>
<h3 id="heading-step-1-install-ripgrep"><strong>Step 1</strong>: Install ripgrep</h3>
<p>If you prefer <a target="_blank" href="https://brew.sh/">Homebrew</a> like I do, run the following to install rg:</p>
<pre><code class="lang-bash">brew tap burntsushi/ripgrep https://github.com/BurntSushi/ripgrep.git
brew install burntsushi/ripgrep/ripgrep-bin
</code></pre>
<p>Here's an <a target="_blank" href="https://gist.github.com/PezCoder/72ba0f5eba3ca5dc7271bde1a1fcfe5e">automated script</a> which I use as part of my <a target="_blank" href="https://github.com/pezcoder/dotfiles">dotfiles</a>.</p>
<p>If you prefer any other mode of installation, refer to ripgrep's official <a target="_blank" href="https://github.com/BurntSushi/ripgrep#installation">installation</a> section.</p>
<h3 id="heading-step-2-install-ackvim"><strong>Step 2</strong>: Install ack.vim</h3>
<p>To install ack.vim using the <a target="_blank" href="https://github.com/junegunn/vim-plug">vim-plug</a> package manager, add the following in your vimrc:</p>
<pre><code class="lang-plaintext">Plug 'mileszs/ack.vim'
</code></pre>
<p>or refer to the ack.vim's <a target="_blank" href="https://github.com/mileszs/ack.vim#installation">installation</a> section.</p>
<h3 id="heading-step-3-configure-ackvim-to-use-rg"><strong>Step 3</strong>: Configure ack.vim to use rg</h3>
<p>Add the following configuration in your vimrc:</p>
<pre><code class="lang-plaintext">" ack.vim --- {{{

" Use ripgrep for searching ⚡️
" Options include:
" --vimgrep -&gt; Needed to parse the rg response properly for ack.vim
" --type-not sql -&gt; Avoid huge sql file dumps as it slows down the search
" --smart-case -&gt; Search case insensitive if all lowercase pattern, Search case sensitively otherwise
let g:ackprg = 'rg --vimgrep --type-not sql --smart-case'

" Auto close the Quickfix list after pressing '&lt;enter&gt;' on a list item
let g:ack_autoclose = 1

" Any empty ack search will search for the work the cursor is on
let g:ack_use_cword_for_empty_search = 1

" Don't jump to first match
cnoreabbrev Ack Ack!

" Maps &lt;leader&gt;/ so we're ready to type the search keyword
nnoremap &lt;Leader&gt;/ :Ack!&lt;Space&gt;
" }}}

" Navigate quickfix list with ease
nnoremap &lt;silent&gt; [q :cprevious&lt;CR&gt;
nnoremap &lt;silent&gt; ]q :cnext&lt;CR&gt;
</code></pre>
<p>Note: <code>let g:ackprg</code> defines the command which ack.vim will internally run.<br>Also note that we're using <code>rg</code> here with some options. Look at the <code>man rg</code> to modify the options that may meet your requirements.</p>
<p>To explore options for ack.vim, look into the following <a target="_blank" href="https://github.com/mileszs/ack.vim/blob/master/doc/ack.txt">documentation</a>.</p>
<h2 id="heading-usage">Usage</h2>
<p>Now that we're up and ready, here are the most common use-cases:</p>
<h3 id="heading-look-for-a-word-under-the-cursor">Look for a word under the cursor</h3>
<p><em>Press / followed by enter</em>.<br>Since we've set <code>let g:ack_use_cword_for_empty_search = 1</code>, Ack falls back to the current word under the cursor for the search, so no need to type that word.</p>
<h3 id="heading-word-search">Word search</h3>
<p><em>Press / followed by the word (without any quotes) &amp; enter.</em><br>Since we're using smart case with ripgrep, that'll do a case insensitive search if the word is all lowercase, and a case sensitive search otherwise.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/06/Screenshot-2020-06-04-at-3.33.02-AM-1.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>word search with ack.vim</em></p>
<h3 id="heading-regex-search">Regex search</h3>
<p><em>Press / followed by a regex pattern in quotes &amp; enter.</em></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/06/Screenshot-2020-06-04-at-3.38.21-AM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>regex search with ack.vim</em></p>
<h3 id="heading-navigation-through-the-results">Navigation through the results</h3>
<p>Ack.vim populates the results in the Quickfix list, which opens up as a separate bottom window. There are multiple ways to navigate the results list:</p>
<ul>
<li><p>You can navigate the Quickfix list using <code>j/k</code> and press <code>enter</code> to close the Quickfix list. VIM will take you to the exact location of the found word.</p>
</li>
<li><p>You can also use the hotkeys <code>]q</code> or <code>[q</code>. VIM will move the cursor to the next/previous result and will open the file in a new buffer if required.<br>  To close the Quickfix list once you're done, you can either go to the bottom Quickfix window and close it or just run <code>:cclose</code></p>
</li>
<li><p>To open the Quickfix list back up, run <code>:copen</code></p>
</li>
</ul>
<h2 id="heading-closing-note">Closing Note</h2>
<p>And there you have it, a seamless search and navigation for your next project-wide keyword search!</p>
<p>If you're stuck anywhere, look for the respective ack.vim and ripgrep docs/issues in their respective repositories, or send me a message. Share the configuration you're proud of, so it can help others improve theirs.</p>
<p>Here are my <a target="_blank" href="https://github.com/pezcoder/dotfiles">dotfiles</a>.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Vim Windows Install Guide – How to Run the Vim Text Editor in PowerShell on your PC ]]>
                </title>
                <description>
                    <![CDATA[ Vim is a powerful code editor. So powerful that both Linux and Mac have it installed by default. But if you are using Windows as your operating system, you will need to install Vim separately. Fortunately, Microsoft makes it very easy to install Vim ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/vim-windows-install-powershell/</link>
                <guid isPermaLink="false">66b8d651bebc010ace8fe6f6</guid>
                
                    <category>
                        <![CDATA[ vim ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Windows 10 ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Quincy Larson ]]>
                </dc:creator>
                <pubDate>Wed, 06 May 2020 17:21:00 +0000</pubDate>
                <media:content url="https://cdn-media-2.freecodecamp.org/w1280/5f9c9b34740569d1a4ca2a64.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Vim is a powerful code editor. So powerful that both Linux and Mac have it installed by default.</p>
<p>But if you are using Windows as your operating system, you will need to install Vim separately.</p>
<p>Fortunately, Microsoft makes it very easy to install Vim and get it running on your PC.</p>
<h2 id="heading-how-to-download-vim">How to Download Vim</h2>
<p>You can <a target="_blank" href="https://www.vim.org/download.php">download the latest version of the Vim Text Editor straight from Vim themselves</a>.</p>
<p>They have built a special self-executing installer that walks you through the process of installing Vim in the right location on your hard drive.</p>
<h2 id="heading-how-to-install-vim">How to Install Vim</h2>
<p>Note that for Windows you will technically download something called gVim, which is a version of Vim that includes a basic graphic user interface (GUI). You can <a target="_blank" href="https://ftp.nluug.nl/pub/vim/pc/gvim82.exe">install it by downloading this executable installer</a>.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/signal-attachment-2020-05-07-144326_005-1.png" alt="Image" width="600" height="400" loading="lazy">
<em>A screenshot of what you'll se when you attempt to open the file. Because this is an .exe file, Windows will ask your permission first.</em></p>
<p>Once you've downloaded the file, you just need to run it, and you'll see a nice installation wizard that looks like this:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/signal-attachment-2020-05-07-144326_004.png" alt="Image" width="600" height="400" loading="lazy">
<em>A screenshot of the wizard you'll see when you first run the Vim installer</em></p>
<p>They have a recommended "typical" installation. but if you have a reasonably large hard drive, there's no harm in going ahead with installing everything by choosing the "full" option:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/signal-attachment-2020-05-07-144326_003.png" alt="Image" width="600" height="400" loading="lazy">
<em>A screenshot of the Vim installer where you can choose what parts of Vim you want to install.</em></p>
<h2 id="heading-how-to-run-vim-in-powershell">How to Run Vim in PowerShell</h2>
<p>Then, once you've installed Vim, you should be able to launch it from your Windows command prompt. </p>
<p>Note that as of 2020, PowerShell has all of the same functionality as CMD, plus a whole lot more. I recommend using PowerShell for everything.</p>
<p>You can open PowerShell from the Windows menu bar by typing "powershell" in the search field on the start bar.</p>
<p>Windows will open PowerShell, and you'll get a command prompt that looks something like this:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/signal-attachment-2020-05-07-144326_001.png" alt="Image" width="600" height="400" loading="lazy">
<em>A screenshot of the Windows PowerShell prompt.</em></p>
<p>Once you're in PowerShell, here's how to run Vim itself. All you have to do is type "vim" and press enter. This will open up Vim. Once Vim is open, this is what you should see:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/signal-attachment-2020-05-07-144326_002.png" alt="Image" width="600" height="400" loading="lazy">
<em>A screenshot of Vim when you open it for the first time.</em></p>
<p>Congratulations – you now have Vim installed.</p>
<h2 id="heading-how-to-run-vim-inside-vs-code">How to run Vim inside VS Code</h2>
<p>If you are already using VS Code, and want a lot of the speed of Vim without losing the functionality of VS Code, I have good news. It is possible to run a Vim-like experience right within VS Code.</p>
<p><a target="_blank" href="https://marketplace.visualstudio.com/items?itemName=vscodevim.vim">Here is a Vim plugin for VS Code</a> that will help you do this. At the time of me writing this, this plugin has been installed nearly 2 million times.</p>
<h2 id="heading-how-to-learn-how-to-use-vim-properly">How to Learn How to Use Vim Properly</h2>
<p>Vim is a powerful code editor, and it will take you a lot of practice to get comfortable with it. </p>
<p>Here are a few Vim tutorials that will really help you quickly grasp the basics and get your fingers flying in no time.</p>
<p>For starters, one way Vim is different from other code editors is that Vim has "modes". Here are <a target="_blank" href="https://www.freecodecamp.org/news/vim-editor-modes-explained/">all of Vim's modes explained, with examples</a>.</p>
<p>Vim can be intimidating. There is so much to learn. But this guide will show you <a target="_blank" href="https://www.freecodecamp.org/news/how-not-to-be-afraid-of-vim-anymore-ec0b7264b0ae/">how not to be afraid of Vim anymore</a>.</p>
<p>If you're already using VS Code and want to switch completely to Vim, <a target="_blank" href="https://www.freecodecamp.org/news/vim-for-people-who-use-visual-studio-code/">this article will explain how you can do so</a>.</p>
<p>And <a target="_blank" href="https://www.freecodecamp.org/news/7-vim-tips-that-changed-my-life/">here are 7 Vim Tips That Changed #100DaysOfCode founder Alex Kallaway's life</a>. In this article, he not only explain these, but shows demos of these tips in action.</p>
<h2 id="heading-vim-learn-it-live-it-love-it">Vim: Learn it, live it, love it.</h2>
<p>In the 30 years since Bram Moolenaar first created Vim, its influence has spread far and wide. And even today, the Vim project is actively maintained and constantly improving.</p>
<p>I've met so many developers over the years who swear by Vim.</p>
<p>I hope this guide has helped you get running Vim on your Windows PC. And I hope these other tutorials I've shared with you here will help you go from zero-to-sixty within the coming months.</p>
<p>The key is to keep practicing and not get discouraged by how many Vim shortcuts there are to remember. Eventually, all of these will become muscle memory, and you'll be flying from one file to another, banging out code like a terminator.</p>
<p>There is no feeling quite as cool as being able to drop into a codebase and immediately start making changes without ever even reaching for a mouse or trackpad. That is the power that Vim promises, and delivers in spades.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ 7 Vim Tips That Changed My Life (With Demo) ]]>
                </title>
                <description>
                    <![CDATA[ By Alex Kallaway Hi, fellow coders! You may have heard of the Vim code editor before, or even used it a bit. There are plenty of resources out there that cover the basics of Vim and I don't want to just do another rewrite of those here. Instead, I wa... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/7-vim-tips-that-changed-my-life/</link>
                <guid isPermaLink="false">66d45f62d7a4e35e38434975</guid>
                
                    <category>
                        <![CDATA[ 100DaysOfCode ]]>
                    </category>
                
                    <category>
                        <![CDATA[ editor ]]>
                    </category>
                
                    <category>
                        <![CDATA[ tips ]]>
                    </category>
                
                    <category>
                        <![CDATA[ vim ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Sat, 02 May 2020 21:24:51 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2020/05/image_2020-04-19_16-22-44.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Alex Kallaway</p>
<p>Hi, fellow coders! You may have heard of the Vim code editor before, or even used it a bit.</p>
<p>There are plenty of resources out there that cover the basics of Vim and I don't want to just do another rewrite of those here. Instead, I want to share some quick tips that I've learned from others while using Vim full time at work.</p>
<p>These are tiny things that you can learn quickly that will make a big difference in your day-to-day work in Vim. They'd definitely made my life easier.</p>
<p>Remember: Vim comes pre-installed on Mac and Linux. You just need to open up your terminal and type "vim" in the command prompt, and you'll open Vim. If you have a Windows computer, <a target="_blank" href="https://www.freecodecamp.org/news/vim-windows-install-powershell/">follow these instructions to install Vim on your PC</a>.</p>
<h2 id="heading-before-we-begin">Before we begin</h2>
<p>If you're interested in Vim but haven't started yet, these are the resources I'd like to recommend:</p>
<ul>
<li><a target="_blank" href="https://www.openvim.com">OpenVim</a> - Interactive Vim Tutorial</li>
<li>vimtutor - this is an interactive command line tutorial that's available and installed on Macs and some Linux distros. Just type <code>vimtutor</code> in your terminal</li>
<li><a target="_blank" href="https://vim-adventures.com/">VimAdventures</a> - First couple of levels are free, and if you like the format, and the full license is $25</li>
</ul>
<p>If you like Vim but it's too much to run it on its own, install a Vim extension for your favourite editor, like VS Code or Sublime or any other. That way you get to use the quick actions and shortcuts of Vim and a friendlier interface you're more used to.</p>
<p>One important realization I had about learning and working with Vim: you don't need to master everything (which is practically impossible anyway) to start using it.</p>
<p>Once you figure out the basics, every time you have a question or a block throughout your workday, write it down, and then go through that list and search the Internet for how to do that in Vim. </p>
<p>This way, you will incrementally fill any gaps you might have and will become better with each new little thing you add to your repertoire (these micro-improvements will be similar to the tips in this article below).</p>
<p>Now let's proceed to the fun stuff – the tips and tricks. You don't have to have any Vim plugins installed to take advantage of these.</p>
<h2 id="heading-1-how-to-start-writing-on-a-line-at-correct-indentation">1. How to start writing on a line at correct indentation</h2>
<p>Before I learned this, I used to jump on a new line and go to insert mode, TAB to the right indentation and start typing code. With this little trick, you won't have to do do all the extra tabbing, it will just place you in insert mode at the right indentation.</p>
<p>RECIPE: <code>S</code> (SHIFT+s)</p>
<p>DEMO:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/vimtips-shift-s.gif" alt="Image" width="600" height="400" loading="lazy"></p>
<h2 id="heading-2-resize-windows-automatically">2. Resize windows automatically</h2>
<p>Very often we do something with windows inside Vim that causes them to be resized incorrectly, sometimes one being way too wide and the other way too narrow. </p>
<p>The easiest way to see that effect is to open 3 windows in one Vim tab and resize the terminal window in which you opened Vim.</p>
<p>You want to resize the windows to all be the same size, with available space evenly distributed. Good news is, you don't have to do it manually.</p>
<p>RECIPE: <code>CTRL+w =</code></p>
<p>The combination of CTRL+w, followed by pressing the equals sign key will equalize the windows.</p>
<p>DEMO:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/vimtips-equalize-3.gif" alt="Image" width="600" height="400" loading="lazy"></p>
<h2 id="heading-3-jump-to-the-matching-bracketbrace">3. Jump to the matching bracket/brace</h2>
<p>With your cursor on a square [ or round ( bracket or a curly brace {, press % (SHIFT+5) to jump to its matching symbol. Press it again to jump back (toggle between them).</p>
<pre><code><span class="hljs-keyword">if</span> (condition) {
  <span class="hljs-comment">// code</span>
}
<span class="hljs-comment">// If your cursor was on {, and you pressed %, you'd jump to }</span>
</code></pre><p>RECIPE: <code>%</code> with your cursor on the character you want to find a match to.</p>
<p>DEMO:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/vimtips-percent.gif" alt="Image" width="600" height="400" loading="lazy"></p>
<h2 id="heading-4-indentunindent-a-line-or-multiple-lines">4. Indent/Unindent a line or multiple lines</h2>
<pre><code>&gt;&gt; ⁠– indents a line
&lt;&lt; ⁠– unindents a line
</code></pre><p>When you have multiple lines selected (in VISUAL LINE mode), you only need to press &gt; or &lt; once to indent or unindent the lines (as shown in demo below)</p>
<p>It doesn't matter where your cursor is positioned in the line when indenting - it will still work. After indent is done, cursor is auto-positioned on first non-empty character in the line.</p>
<p>RECIPE: One line: <code>&gt;&gt;</code>, <code>&lt;&lt;</code>. Multiple lines: <code>&gt;</code>, <code>&lt;</code>.</p>
<p>DEMO:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/vimtips-move-a-line.gif" alt="Image" width="600" height="400" loading="lazy"></p>
<h2 id="heading-5-fix-indentation-in-the-whole-file">5. Fix indentation in the whole file</h2>
<p>Start in the top of a file (to get there, press <code>gg</code> anywhere in the file.). Then press <code>=G</code>, and Vim will fix the indentation in the whole file. If you don't start in the beginning of the file, it will fix indentation from current line to the bottom of file.</p>
<p>RECIPE: <code>=G</code></p>
<p>Press the equals sign, followed by SHIFT+G</p>
<p>DEMO:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/vimtips-format.gif" alt="Image" width="600" height="400" loading="lazy"></p>
<h2 id="heading-6-basics-of-working-with-tabs">6. Basics of working with tabs</h2>
<p>Often you want to be looking at multiple files or contexts at the same time. Vim tabs are very handy but underutilized feature for this. I don't know of any other editor that supports this (but I'm sure there is a way to do it elsewhere). </p>
<p>For example, I like to keep my code related files in my main tab, and in another tab: README with a TODO list and a place I can jot down further ideas.</p>
<p>To write the commands to work with tabs, you will need to be in command mode. To start writing the command, press <code>:</code> and type. The command will show up in the left bottom corner of the editor as you are typing. Press enter to execute.</p>
<p>RECIPE:<br><code>:tabnew</code> creates a new tab<br><code>gt</code> - go to next tab<br><code>gT</code> - go to previous tab<br><code>:tabo</code> - close all other tabs besides the active one</p>
<p>DEMO:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/vimtips-tabs.gif" alt="Image" width="600" height="400" loading="lazy"></p>
<h2 id="heading-7-how-to-quickly-go-back-to-a-previous-file">7. How to quickly go back to a previous file</h2>
<p>Often, when you edit a file with code, you open another one in the same window. Then it's not so easy to come back to the one you just worked on. You could list buffers and navigate to the previous one but you need to remember its name for that and spend your precious time. Vim users don't like to spend too much time on actions. :) So you can use CTRL+o for this.</p>
<p>All it does is that it finds a previous position of your cursor - and if it happened to be in a different file (the one you just lost by opening a new one), it jumps us right back there.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/05/vimtips-ctrl-o.gif" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Thank you for reading and I hope these tips serve you well!  </p>
<p>? If you want to follow my adventures, <a target="_blank" href="https://twitter.com/ka11away">here's my Twitter</a> :)</p>
<p>? I write a weekly newsletter that covers topics like learning to code, changing habits, personal finance, book recommendations &amp; key takeaways, minimalism, starting a business, psychology and more. For those of you who are interested: join 1K+ like-minded people passionate about self-improvement and learning.<br><a target="_blank" href="https://www.dotheoppo.site/newsletter">Subscribe here</a></p>
<p>? These days I am working on my side project - an app called "Zerno". Sign up to get early access very soon!<br><a target="_blank" href="https://www.zerno.app">ZERNO app</a></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Vim Editor Modes Explained ]]>
                </title>
                <description>
                    <![CDATA[ Because Vim is focused on changing existing code just as much as writing new code, it is split into several modes that each have different purposes. Normal Mode By default, Vim starts in “normal” mode. Normal mode can be accessed from other modes by ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/vim-editor-modes-explained/</link>
                <guid isPermaLink="false">66c3648b1917b5c625ae4b09</guid>
                
                    <category>
                        <![CDATA[ editor ]]>
                    </category>
                
                    <category>
                        <![CDATA[ vim ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Wed, 18 Dec 2019 22:07:00 +0000</pubDate>
                <media:content url="https://cdn-media-2.freecodecamp.org/w1280/5f9c9ea2740569d1a4ca3e40.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Because Vim is focused on changing existing code just as much as writing new code, it is split into several modes that each have different purposes.</p>
<h3 id="heading-normal-mode"><strong>Normal Mode</strong></h3>
<p>By default, Vim starts in “normal” mode. Normal mode can be accessed from other modes by pressing <code>Esc</code> or <code>&lt;C-[&gt;</code>.</p>
<p>In Normal mode key presses don’t work as one would expect. That is, they don’t insert text into the document; instead, certain key presses can:</p>
<h4 id="heading-move-the-cursor"><strong>Move the cursor</strong></h4>
<ul>
<li><strong>h</strong> move one character left</li>
<li><strong>j</strong> move one row down</li>
<li><strong>k</strong> move one row up</li>
<li><strong>l</strong> move one character right</li>
</ul>
<p>As many vim commands, row movement can be prefixed by a number to move s everal lines at a time:</p>
<ul>
<li><strong>4j</strong> move 4 rows down</li>
<li><strong>6k</strong> move 6 rows up  </li>
</ul>
<p>Basic word movements:</p>
<ul>
<li><strong>w</strong> move to beginning of next word</li>
<li><strong>b</strong> move to previous beginning of word</li>
<li><strong>e</strong> move to end of word</li>
<li><strong>W</strong> move to beginning of next word after a whitespace</li>
<li><strong>B</strong> move to beginning of previous word before a whitespace</li>
<li><strong>E</strong> move to end of word before a whitespace</li>
</ul>
<p>Beginning/End of line movement:</p>
<ul>
<li><strong>0</strong> move to the beginning of the line</li>
<li><strong>$</strong> move to the end of the line</li>
</ul>
<h4 id="heading-manipulate-text"><strong>Manipulate text</strong></h4>
<h4 id="heading-enter-other-modes"><strong>Enter other modes</strong></h4>
<p><strong>Normal mode</strong> is where one should spend most of their time while using Vim. Remember, this is what makes Vim different.</p>
<p>In normal mode, there are multiple ways to move around an open file. In addition to using the cursor keys to move around, you can use <code>h</code> (left), <code>j</code> (down), <code>k</code> (up), and <code>l</code> (right) to move as well. This particularly helps touch typists who don’t like leaving the home row when making changes.</p>
<p>You can also make changes to single characters in normal mode. For example, to replace a single character, move your cursor over it and press <code>r</code>, and then the character you want to replace it with. Similarly, you can delete single characters by moving your cursor over it and pressing <code>x</code>.</p>
<p>To perform an undo, press <code>u</code> in normal mode. This undoes changes up to the last time you were in normal mode. If you want to redo (<em>i.e.</em>, undo your undo) press <code>Ctrl+r</code> in normal mode.</p>
<h3 id="heading-insert-mode"><strong>Insert Mode</strong></h3>
<p>This is the second most used mode, and will be the most familiar behavior to most people. Once in insert mode, typing inserts characters just like a regular text editor. You can enter it by using an insert command from normal mode.</p>
<p>Insert commands include:</p>
<ul>
<li><code>i</code> for ’<strong>i</strong>nsert’, this immediately switches vim to insert mode</li>
<li><code>a</code> for ’<strong>a</strong>ppend’, this moves the cursor after the current character and enters insert mode</li>
<li><code>o</code> inserts a new line below the current line and enters insert mode on the new line</li>
</ul>
<p>These commands have an uppercase variety too:</p>
<ul>
<li><code>I</code> moves the cursor to the beginning of the line and enters insert mode</li>
<li><code>A</code> moves the cursor to the end of the line and enters insert mode</li>
<li><code>O</code> inserts a new line above the current one and enters insert mode on the new line</li>
</ul>
<p>There are so many more ways of inserting text in Vim that can’t be listed here but these are the simplest. Also, beware of staying in insert mode for too long; Vim is not designed to be used in insert mode all the time.</p>
<p>To leave insert mode and return to normal mode, press <code>Esc</code> or <code>&lt;C-[&gt;</code></p>
<h3 id="heading-visual-mode"><strong>Visual Mode</strong></h3>
<p>Visual mode is used to make selections of text, similar to how clicking and dragging with a mouse behaves. Selecting text allows commands to apply only to the selection, such as copying, deleting, replacing, and so on.</p>
<p>To make a text selection:</p>
<ul>
<li>Press <code>v</code> to enter visual mode, this will also mark a starting selection point</li>
<li>Move the cursor to the desired end selection point; vim will provide a visual highlight of the text selection</li>
</ul>
<p>Visual mode also has the following variants:</p>
<ul>
<li><code>V</code> to enter visual line mode, this will make text selections by line</li>
<li><code>&lt;C-V&gt;</code> to enter visual block mode, this will make text selections by blocks; moving the cursor will make rectangle selections of the text</li>
</ul>
<p>To leave visual mode and return to normal mode, press <code>Esc</code> or <code>&lt;C-[&gt;</code>.</p>
<p>The visual mode actually has multiple subtypes: <em>visual</em>, <em>block-visual</em> and <em>linewise-visual</em></p>
<ul>
<li><em>visual</em>: like described above. Enter by pressing <code>v</code></li>
<li><em>block-visual</em>: select any rectangular region. Enter by pressing <code>&lt;ctrl&gt;+v</code></li>
<li><em>linewise-visual</em>: always select full lines. Enter by pressing <code>&lt;shift&gt;+v</code></li>
</ul>
<h3 id="heading-command-mode"><strong>Command Mode</strong></h3>
<p>Command mode has a wide variety of commands and can do things that normal mode can’t do as easily. To enter command mode type ’:’ from normal mode and then type your command which should appear at the bottom of the window. For example, to do a global find and replace type <code>:%s/foo/bar/g</code> to replace all ‘foo’ with ‘bar’</p>
<ul>
<li><code>:</code> Enters command mode</li>
<li><code>%</code> Means across all lines</li>
<li><code>s</code> Means substitute</li>
<li><code>/foo</code> is regex to find things to replace</li>
<li><code>/bar/</code> is regex to replace things with</li>
<li><code>/g</code> means global, otherwise it would only execute once per line</li>
</ul>
<p>Vim has a number of other methods that you can read about in the help documentation, <code>:h</code> or <code>:help</code>.</p>
<h3 id="heading-replace-mode"><strong>Replace Mode</strong></h3>
<p>Replace mode allows you replace existing text by directly typing over it. Before entering this mode, get into normal mode and put your cursor on top of the first character that you want to replace. Then press ‘R’ (capital R) to enter replace mode. Now whatever you type will replace the existing text. The cursor automatically moves to the next character just like in insert mode. The only difference is that every character you type will replace the existing one.</p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
