<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Cristian Zapata</title>
    <description>The latest articles on DEV Community by Cristian Zapata (@theposi).</description>
    <link>https://dev.to/theposi</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1411705%2F7cdbce4e-6529-4c1f-853a-ca3a8aea0499.png</url>
      <title>DEV Community: Cristian Zapata</title>
      <link>https://dev.to/theposi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/theposi"/>
    <language>en</language>
    <item>
      <title>Portable configurations with dotfiles and GNU Stow 🐧</title>
      <dc:creator>Cristian Zapata</dc:creator>
      <pubDate>Wed, 22 May 2024 19:09:36 +0000</pubDate>
      <link>https://dev.to/theposi/portable-configurations-with-dotfiles-and-gnu-stow-377</link>
      <guid>https://dev.to/theposi/portable-configurations-with-dotfiles-and-gnu-stow-377</guid>
      <description>&lt;p&gt;Since I started using Linux, I realized the great capacity it gives us as developers to interact directly with the system through the terminal. It's fantastic, but for very curious people like me, it can be a bit dangerous. Playing around in the terminal, I deleted something I shouldn't have and had to reinstall the operating system, a funny anecdote in my opinion. However, the issue changed when I had to reinstall all the applications I use and, on top of that, configure them from scratch.&lt;/p&gt;

&lt;p&gt;Like everything in life, you have to see the good side of things and view everything as a learning opportunity. I started thinking, "Is there a way to save my configurations and apply them more easily?" And yes, it can be done, and today I'll show you how. But first...&lt;/p&gt;

&lt;h1&gt;
  
  
  What are dotfiles?
&lt;/h1&gt;

&lt;p&gt;Simply put, dotfiles is a repository where we store all our configuration files for the applications we use daily. These files are usually hidden because they start with a dot (.), hence the name dotfiles.&lt;/p&gt;

&lt;p&gt;We can also set up specific scripts for certain tasks or our aliases to improve our terminal workflow. If you don't know what an alias is or how to implement one, &lt;a href="https://theposintech.hashnode.dev/simplify-your-terminal-commands"&gt;here&lt;/a&gt; is my blog on the topic for you to check out.&lt;/p&gt;

&lt;h1&gt;
  
  
  What will we need?
&lt;/h1&gt;

&lt;p&gt;First of all, we must consider that usage and implementation vary from system to system, so in this blog, we'll see how to do it on our favorite penguin system 🐧.&lt;/p&gt;

&lt;h3&gt;
  
  
  Git and GitHub
&lt;/h3&gt;

&lt;p&gt;As mentioned earlier, we will be working with a repository, so we will need Git to manage all our changes and keep track of the updates we make. Additionally, we need a place in the cloud to store them and have them available from any computer where we want to implement them, so I recommend GitHub.&lt;/p&gt;

&lt;h3&gt;
  
  
  Stow
&lt;/h3&gt;

&lt;p&gt;This application, which is part of the GNU project, is the magic behind dotfiles as it will allow us to create symbolic links for our configuration files from our dotfiles to the configuration files originally in our system, ensuring they apply correctly.&lt;/p&gt;

&lt;h3&gt;
  
  
  IDE and Terminal
&lt;/h3&gt;

&lt;p&gt;Lastly, we will need a terminal to run various commands for both Git and Stow and a text editor to make the different configurations we want in our applications. I recommend using Vi, Vim, or Neovim since they can be used from the terminal and unify the development process, but this is a personal choice.&lt;/p&gt;

&lt;h1&gt;
  
  
  Useful Commands
&lt;/h1&gt;

&lt;p&gt;Here are some commands that will greatly help us achieve our goal and interact more easily with our file system from the terminal. Something to consider is that these commands work for Unix-based systems like Mac and Linux.&lt;/p&gt;

&lt;p&gt;Move to a directory&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;folderName
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Go back to the previous directory&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; ..
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Move to the home directory&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a directory&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;folderName
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Delete a directory&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# If it's empty&lt;/span&gt;
&lt;span class="nb"&gt;rm &lt;/span&gt;folderName

&lt;span class="c"&gt;# If it's not empty&lt;/span&gt;
&lt;span class="nb"&gt;rm&lt;/span&gt; &lt;span class="nt"&gt;-rf&lt;/span&gt; folderName
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;List the contents of a directory with a detailed format, including hidden files (only works with directories).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Affects the current directory&lt;/span&gt;
&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-la&lt;/span&gt;

&lt;span class="c"&gt;# Affects the specified directory&lt;/span&gt;
&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-la&lt;/span&gt; /folderName
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;View the content of a file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cat &lt;/span&gt;fileName
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Usando touch&lt;/span&gt;
&lt;span class="nb"&gt;touch &lt;/span&gt;fileName

&lt;span class="c"&gt;# Usando vim&lt;/span&gt;
vim fileName
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Delete a file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;rm &lt;/span&gt;fileName
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Development
&lt;/h1&gt;

&lt;p&gt;Now that we know everything we'll need, we can begin our mission. The first thing we need to do is create the folder for our dotfiles in our home directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nv"&gt;$HOME&lt;/span&gt;/dotfiles
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we need to initialize a repository in our dotfiles directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Move to the directory&lt;/span&gt;
&lt;span class="nb"&gt;cd &lt;/span&gt;dotfiles

&lt;span class="c"&gt;# Initialize the repository&lt;/span&gt;
git init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we run the &lt;code&gt;git status&lt;/code&gt; command to check the status of our repository. It should look something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;On branch master

No commits yet

nothing to commit &lt;span class="o"&gt;(&lt;/span&gt;create/copy files and use &lt;span class="s2"&gt;"git add"&lt;/span&gt; to track&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At this point, we can push our repository from local to remote, following the guide on GitHub.&lt;/p&gt;

&lt;p&gt;Before using Stow, we need to ensure that the structure of our dotfiles matches the structure of the configuration files as they are by default in our system.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvcw0e7mwt4gf31ddkoo9.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvcw0e7mwt4gf31ddkoo9.jpg" alt="Image description" width="800" height="462"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also, the files we want to link cannot exist in the destination before running the stow command, as trying to create the link will result in an error. To fix this, we will delete the files in our destination, which is our home in this case.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;rm &lt;/span&gt;fileName
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or, as a personal recommendation, you can rename them instead.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mv &lt;/span&gt;fileName.txt fileName.back
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With this done, we run our command to create the links. It's very important to run the command from the main dotfiles folder.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;stow &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we can go to our home directory to verify if the links were created correctly. We can check this by listing our files and seeing something like this:&lt;/p&gt;

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

&lt;p&gt;Here we can see how our &lt;code&gt;init.lua&lt;/code&gt; file in our home is linked and taking the content from our &lt;code&gt;init.lua&lt;/code&gt; in our dotfiles.&lt;/p&gt;

&lt;p&gt;With this setup, we can start adding all the configuration files for our applications, scripts to run when needed, or anything we can imagine. You can make your dotfiles whatever you want.&lt;/p&gt;

&lt;p&gt;When you switch systems and want to apply your configurations, you just need to clone the repository in the home, rename the default files, and run stow from the dotfiles.&lt;/p&gt;

&lt;h1&gt;
  
  
  Thank you!
&lt;/h1&gt;

&lt;p&gt;I hope this helps you as much as it has helped me to have my configurations always at hand and gives me great flexibility to work on any system I want.&lt;/p&gt;

&lt;p&gt;Here are my &lt;a href="https://github.com/theposi/dotfiles"&gt;dotfiles&lt;/a&gt; so you can have an idea of how I'm working on them, and of course, any improvements are welcome :).&lt;/p&gt;

&lt;p&gt;If you found this interesting or know someone who might benefit from this, don't hesitate to share it. It would help me a lot.&lt;/p&gt;

&lt;p&gt;And finally, if you want to contact me, don't hesitate to say hi on &lt;a href="https://www.instagram.com/theposintech/"&gt;Instagram&lt;/a&gt; or &lt;a href="https://github.com/theposi"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Blessings, folks! &lt;/p&gt;

</description>
      <category>linux</category>
      <category>git</category>
      <category>systems</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Simplify your terminal commands</title>
      <dc:creator>Cristian Zapata</dc:creator>
      <pubDate>Mon, 22 Apr 2024 16:16:23 +0000</pubDate>
      <link>https://dev.to/theposi/whats-an-alias-in-linux-2507</link>
      <guid>https://dev.to/theposi/whats-an-alias-in-linux-2507</guid>
      <description>&lt;p&gt;As a fellow developer, I'm sure you've found yourself navigating your terminal to manage files, run scripts, or handle git commands. And let's be honest, some of these tasks can be pretty repetitive, right? Ever wondered, "Is there a faster or easier way to do this?" If not, I bet you will eventually. And that's where this blog comes in handy. Today, I'll show you how to level up your workflow with some terminal tricks.&lt;/p&gt;

&lt;p&gt;Take, for instance, being in your system's home folder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;theposintech@cristian &lt;span class="k"&gt;in&lt;/span&gt; ~
👾
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, imagine wanting to move to your project folder located at &lt;code&gt;home/Documents/development/projects/myRust_app&lt;/code&gt;. Typing out that entire path every time is a drag. Or consider committing changes to your project. It's a whole process, right? But guess what? You can create custom shortcuts for these tasks using something called &lt;code&gt;alias&lt;/code&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  What is an alias?
&lt;/h1&gt;

&lt;p&gt;An &lt;code&gt;alias&lt;/code&gt; is like a cheat code for your commands. It lets you create shortcuts for lengthy commands, making them quicker to type and easier to remember.&lt;/p&gt;

&lt;p&gt;Here's how you structure an alias:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fez82qdnz48l0ctmqsej9.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fez82qdnz48l0ctmqsej9.jpg" alt="Image description" width="800" height="296"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, how do we put this into action? Well, we need to move into our shell 🐚 configuration file. In my case, I'm using &lt;code&gt;zsh&lt;/code&gt;, so I'll head over to &lt;code&gt;~/.config&lt;/code&gt; and open up &lt;code&gt;nvim .zshrc&lt;/code&gt;. If you're using bash, it's &lt;code&gt;.bashrc&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In this file, we'll use the &lt;code&gt;alias&lt;/code&gt; property to assign a name to our new command and specify the command it should run.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;alias &lt;/span&gt;&lt;span class="nv"&gt;gst&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"git status"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save the changes (in neovim, &lt;code&gt;:w&lt;/code&gt; to save and &lt;code&gt;:q&lt;/code&gt; to close) and then run this command in your terminal (if you're using zsh like me):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;exec &lt;/span&gt;zsh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, you can run your new command in the terminal. But what if you need your &lt;code&gt;alias&lt;/code&gt; to do something dynamic, like prompting you for input? Say, when you're committing changes and need to specify a message. In that case, you can define an input for your alias like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;alias &lt;/span&gt;&lt;span class="nv"&gt;gcm&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'git commit -m "$reach: $*"'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, when you use it in your terminal, you'll replace those parameters with your messages.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcm feat terminal workflow improved!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Where the final output will be &lt;code&gt;"feat: terminal workflow improved!"&lt;/code&gt;, Buut if we want to go forther we can use multiple commands in the same alias, let's to continue with our last example.&lt;/p&gt;

&lt;p&gt;So, we've committed our changes. Now, let's push them to our repo with &lt;code&gt;git push&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;alias &lt;/span&gt;&lt;span class="nv"&gt;gcm&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'git commit -m "$reach: $*" &amp;amp;&amp;amp; git push'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With the &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt;, the command on the right executes immediately after the left one finishes.&lt;/p&gt;

&lt;h1&gt;
  
  
  To consider
&lt;/h1&gt;

&lt;p&gt;The alias we configure in our term will just work on our terminal (zsh), and if we want to use them in another one we have to configure them in that specific term too.&lt;/p&gt;

&lt;h1&gt;
  
  
  Thank you!
&lt;/h1&gt;

&lt;p&gt;I hope this blog helps you streamline your console time and supercharge your developer productivity. If it does, don't hesitate to share it with your friends so they can level up too.&lt;/p&gt;

&lt;p&gt;If you wanna share knowledge feel free on say hi on &lt;a href="https://www.instagram.com/theposintech/"&gt;Instagram&lt;/a&gt; or &lt;a href="https://github.com/theposi"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Happy coding, folks!🐧&lt;/p&gt;

</description>
      <category>linux</category>
      <category>tutorial</category>
      <category>productivity</category>
      <category>devops</category>
    </item>
    <item>
      <title>Mastering variable renaming with gn motion</title>
      <dc:creator>Cristian Zapata</dc:creator>
      <pubDate>Thu, 18 Apr 2024 10:01:41 +0000</pubDate>
      <link>https://dev.to/theposi/mastering-variable-renaming-with-gn-motion-1ibd</link>
      <guid>https://dev.to/theposi/mastering-variable-renaming-with-gn-motion-1ibd</guid>
      <description>&lt;p&gt;Imagine that we have a variable named &lt;code&gt;myVar&lt;/code&gt;, and one of our teammates was reading our code and tell us that it's not descriptive at all but we've used it in numerous places throughout our code, and changing its name step by step isn't an easy task. This is where the "&lt;code&gt;gn&lt;/code&gt;" motion snippet becomes incredibly useful. Let's explore how we can use it.&lt;/p&gt;

&lt;p&gt;To begin, place the cursor above the word we want to rename in this case: &lt;code&gt;myVar&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Then, press &lt;code&gt;*&lt;/code&gt; to search for all instances of the word in the document and start working on it. This highlights all occurrences of the word, enabling quick navigation between them.&lt;/p&gt;

&lt;p&gt;Next, press &lt;code&gt;shift + n&lt;/code&gt; to move to the previous occurrence of the word in our document. Here, press &lt;code&gt;g + n&lt;/code&gt; to operate on this occurrence, which is where the real magic happens. &lt;code&gt;g + n&lt;/code&gt; allows for actions such as editing or renaming.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1712255500078%2Fb8b5588d-8328-4879-a23d-c7b82d2e6ab5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1712255500078%2Fb8b5588d-8328-4879-a23d-c7b82d2e6ab5.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, press &lt;code&gt;c&lt;/code&gt; to change the actual name and input the new one for our variable (this time, try that be something easy to understand), and then press &lt;code&gt;Esc&lt;/code&gt; to finish editing that word. The Escape key exits the renaming mode, returning you to normal mode after inputting the new variable name.&lt;/p&gt;

&lt;p&gt;Pressing &lt;code&gt;n&lt;/code&gt; moves the cursor to the next occurrence of the word in the document, allowing for seamless continuation of the renaming process.&lt;/p&gt;

&lt;p&gt;Finally, &lt;code&gt;.&lt;/code&gt; repeats the last change made in the text editor. After renaming one occurrence of the word, pressing &lt;code&gt;.&lt;/code&gt; applies the same change to the next occurrence, accelerating the renaming process.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1712256223406%2F42b1f986-fedc-45f8-8e2b-6a9e7bb42e8c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1712256223406%2F42b1f986-fedc-45f8-8e2b-6a9e7bb42e8c.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Buuut there's another useful way to do this and is with the &lt;code&gt;substitute command&lt;/code&gt;, let's check it out.&lt;/p&gt;

&lt;p&gt;The first step is to exit any active mode by pressing the &lt;code&gt;Esc&lt;/code&gt; key. Then, use the substitute command &lt;code&gt;:s&lt;/code&gt;. As our intention is to rename all occurrences of our variable &lt;code&gt;myVar&lt;/code&gt;, follow these steps:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1712258414240%2Ffc3cd229-f6fc-45a2-929b-a084ed905799.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1712258414240%2Ffc3cd229-f6fc-45a2-929b-a084ed905799.jpeg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So the final command will looks like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1712258447301%2Fae188d18-3dbb-43e3-9011-c830ff99a0b1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1712258447301%2Fae188d18-3dbb-43e3-9011-c830ff99a0b1.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And if you're that curious as me, you might be wondering, &lt;strong&gt;What's the difference?&lt;/strong&gt; or &lt;strong&gt;When should I use one or the other?&lt;/strong&gt; Well, let me tell you with an example:&lt;/p&gt;

&lt;p&gt;Suppose you have a variable named &lt;code&gt;i&lt;/code&gt; for indexing purposes. In such cases, the "&lt;code&gt;gn&lt;/code&gt;" motion is the preferred method for renaming. And this is because while the substitute command &lt;code&gt;:s&lt;/code&gt; would alter all instances of &lt;code&gt;i&lt;/code&gt;, including occurrences within words like &lt;code&gt;function&lt;/code&gt;, &lt;code&gt;int&lt;/code&gt;, &lt;code&gt;if&lt;/code&gt;, &lt;code&gt;void&lt;/code&gt;, &lt;code&gt;size&lt;/code&gt;, and others, "&lt;code&gt;gn&lt;/code&gt;" provides finer control. By navigating with the &lt;code&gt;n&lt;/code&gt; key and applying the changes with &lt;code&gt;.&lt;/code&gt;, you can selectively modify specific words.&lt;/p&gt;

&lt;p&gt;So in conclusion use &lt;code&gt;:s&lt;/code&gt; for terms that won't disrupt your code or when you want to modify all occurrences deliberately. And opt for the "&lt;code&gt;gn&lt;/code&gt;" motion in scenarios with numerous occurrences, allowing you to selectively choose which ones to modify.&lt;/p&gt;

&lt;p&gt;Now the next time you find yourself needing to rename variables or make widespread changes in your code you can do it faster and efficiently.&lt;/p&gt;

&lt;p&gt;Thank you for read and I really hope this helps you to improve in Neovim, shared if you know someone else can be useful too, Blessings!.&lt;/p&gt;

&lt;p&gt;Useful links:&lt;br&gt;&lt;br&gt;
&lt;a href="https://vim.fandom.com/wiki/Search_and_replace" rel="noopener noreferrer"&gt;Search and replace&lt;/a&gt;&lt;/p&gt;

</description>
      <category>vim</category>
      <category>webdev</category>
      <category>tutorial</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
