#100DaysOfCloudDevOps Challenge — Day 05 — Editors

#100DaysOfCloudDevOps Challenge — Day 05 — Editors

·

4 min read

Welcome to Day 05 of my #100DaysOfCloudDevOps challenge!

In this article, I'll introduce two essential tools for editing files in a terminal: nano and vim. These editors cater to different needs and skill levels. Nano offers simplicity, displaying text as you type and providing straightforward commands like "CTRL + X" for saving. Vim, favored by programmers, boasts extensive capabilities but requires mastering modes and commands like ":wq" for saving and exiting. Explore the contrasts in ease of use, editing modes, and audience suitability to determine which suits your needs: the user-friendly Nano or the powerful yet challenging Vim.

What are file editors?

File Editors are tools we use to make or change files on our computer. File editors are software tools used to create, modify, and manipulate text-based files on a computer. They allow users to view, edit, and save changes to the content of files such as text documents, configuration files, scripts, and code files. File editors come with various features such as syntax highlighting, search and replace functionality, indentation support, and keyboard shortcuts to streamline editing tasks. Examples of file editors include Notepad, Sublime Text, Atom, Visual Studio Code, nano, vim, and emacs.

There are many choices, but let's focus on the two main editors you'll find in a terminal or command line. I've tried both, and I prefer nano for simple edits because it's easy to use. However, vim has more features and can do a lot more once you get the hang of it.

Nano

Nano follows a WYSIWYG (What You See Is What You Get) approach, meaning that what you see on the screen is what you get in the file.

  • If you type "nano 100DayOfCloudDevOps.txt", you'll create a blank file named "100DayOfCloudDevOps.txt". Then, you can start typing your text into the file.

    At the bottom of the screen, you will see an easy-to-follow instructions what you can do with the file.

  • Write something inside the 100DayOfCloudDevOps.txt. and save it by using CTRL + X (save and exit) and follow the rest of the instructions.

  • Now let's check the content of the file we just made, using cat command.

nano is really simple when I need to make small tweaks to configuration files.

Vim

Vim (short for Vi Improved) is preferred by programmers and power users.

  • Here we use vim 100DayOfCloudDevOps.txt. to open the file we created earlier. You are going to first see the lack of help menus at the bottom. Don't get scared, there's a way to get you out of here.

    Press the esc button then type :q

    Hooray! You just learned how to exit the vim editor.

  • Vim comes with a handy tool called vimtutor. It's like a guide that teaches you all the basic Vim commands so you can use Vim for editing files easily. To exit press esc then type :q .

  • Let's try Insert Mode together.

    When we type vim 100DaysOfCloudDevOps.txt in Vim, you begin in normal mode. There are other modes like command, normal, visual, and insert. If you want to add text, you switch from normal to insert mode by pressing "i". After adding text, to save changes, you hit "escape" and then type ":wq" to save and exit

So what's the key differences between these two editors?

  • Ease of Use:

    • Nano: Simple and easy to use.

    • Vim: Powerful but challenging to master.

  • Editing Modes:

    • Nano: Modeless (works in a single mode).

    • Vim: Mode-based (switch between modes for different tasks).

  • Shortcuts:

    • Nano: CTRL + F (forward), CTRL + B (backward), CTRL + N (next line), CTRL + P (previous line), CTRL + X (save and exit).

    • Vim: h (left), I (right), j (down), k (up), :wq (save and exit).

  • Audience:

    • Nano: Newcomers.

    • Vim: Experienced users, especially programmers.

In summary, choose Nano if you’re starting out or prefer simplicity, and opt for Vim if you’re ready to explore a powerful, customizable editor with a steeper learning curve.


Find the GitHub repo here.

I trust we all learned something from this blog. If you found it helpful too, give back and show your support by clicking heart or like, share this article as a conversation starter and join my newsletter so that we can continue learning together and you won’t miss any future posts.

Thanks for reading until the end! If you have any questions or feedback, feel free to leave a comment.

Did you find this article valuable?

Support anj in tech by becoming a sponsor. Any amount is appreciated!