Chapter 4 - Text Editors
Hello. I am a DevOps enthusiast from Nigeria. I am also passionate about Technical Writing.
As a passionate DevOps enthusiast, I'm dedicated to bridging the gap between development and operations teams. With a strong foundation in Linux, Git, Docker, and Kubernetes, I excel in creating efficient, scalable, and reliable software delivery pipelines.
With a keen eye for detail and a passion for continuous learning, I stay up-to-date with industry trends and best practices. My goal is to collaborate with like-minded professionals, share knowledge, and drive innovation in the DevOps space.
I look forward to sharing with you, all I've learned so far in my DevOps journey.

Introduction
Text editors are essential tools in Linux for editing configuration files, writing scripts, and even developing software. In this chapter, we will explore some of the most commonly used text editors and their basic usage.
Common Text Editors
Linux offers a variety of text editors, each with its own unique features and user interface. Two of the most commonly used text editors are nano and vim.
nano
nano is a simple, user-friendly text editor that is ideal for beginners. It provides an easy-to-use interface with straightforward commands displayed at the bottom of the screen.
Features of nano:
Easy to learn and use
Commands are displayed at the bottom of the screen
Suitable for quick edits and small files
Installation
NB: nano is installed by default on many Linux distributions, so you might not need to install it explicitly. You can check if it is already installed by running nano --version in your terminal. If it is not installed, here are the commands for installing nano on various Linux distributions.
Debian/Ubuntu:
sudo apt-get install nanoFedora:
sudo dnf install nanoRed Hat Enterprise Linux (RHEL)/CentOS:
sudo yum install nanoopenSUSE:
sudo zypper install nanoArch Linux:
sudo pacman -S nano
vim
vim (Vi IMproved) is a powerful and highly configurable text editor. It is an enhanced version of the older vi editor. vim offers a wide range of advanced features and flexibility, but it has a steeper learning curve compared to nano.
Features of vim:
Highly customizable
Supports multiple modes (normal, insert, visual, and command-line)
Extensive plugin ecosystem
Suitable for complex editing tasks and large projects
Installation
NB: vim is installed by default on many Linux distributions, so you might not need to install it explicitly. You can check if it is already installed by running vim --version in your terminal. If it is not installed, here are the commands for installing vim on various Linux distributions.
Debian/Ubuntu:
sudo apt-get install vimFedora:
sudo dnf install vimRed Hat Enterprise Linux (RHEL)/CentOS:
sudo yum install vimopenSUSE:
sudo zypper install vimArch Linux:
sudo pacman -S vim
Basic Usage
Now that we are familiar with nano and vim, let's explore their basic usage, including how to open, edit, save, and close files.
Opening Files
nano: To open a file with
nano, use the following command:nano filename
If the file does not exist, nano will create a new file with the specified name.
vim: To open a file with
vim, use the following command:vim filename
Similar to nano, if the file does not exist, vim will create a new file with the specified name.
Editing Files
nano: In
nano, you can start typing to edit the file. The arrow keys can be used to navigate through the text.vim: In
vim, you need to switch to insert mode to edit the text. Pressito enter insert mode, then start typing. To return to normal mode, pressEscorctrl+[keys.
Saving Files
nano To save changes in
nano, pressCtrl+O, then pressEnterto confirm the filename. Then pressCtrl+Xto exit the editor.vim To close
vim, first ensure you are in normal mode by pressingEscorctrl+[keys, then type:qand press Enter. If there are unsaved changes, you can use:wqto save and exit or:q!to exit forcefully without saving.
Conclusion
In this chapter, we covered two common text editors in Linux: nano and vim. We explored their basic usage, including how to open, edit, save, and close files. Whether you are a beginner or an advanced user, knowing how to use at least one of these text editors will enhance your ability to manage and configure your Linux system efficiently.
Feel free to leave comments and share this article. Follow my blog for more insights on Linux!